I have an HTML (multi) select list containing a list of network devices.
<select id="Printers" multiple="multiple" name="Printers"> <option value="\\ABCDEF01\PRINTER1\">\\ABCDEF01\PRINTER1\</option> <option value="\\ABCDEF02\PRINTER2">\\ABCDEF02\PRINTER2</option> ... ... </select>
I want to automatically select values ββusing javascript. This is the code I'm currently using:
//Assume: val.Name == "\\ABCDEF02\PRINTER2" var select = document.getElementById('Printers'); var escapedName = val.Name.replace(/\\/g, "\\\\"); // Escape backslashes. $("option[value=\"" + escapedName + "\"]", select).attr('selected', 'selected');
This code works in chrome but not in IE7. Is there any quirk I should know that this would prevent IE7 from working properly?
source share