Jump to content

DropList Script help


ibrahimjan

Recommended Posts

Sorry guys I need help with the following JS script, what I need to do is put a different values for "actual" to "select" but when I do that the two fields do not work, they do not copy each other, is there a way we can change the JS script to allow me to do that, please help, I hope I posted this in the correct place, any help is much appreciated.this is the html:<select name="select" onchange="listSel(this,'actual')"> <option value="0"selected="selected">Design Only</option> <option value="16">Design & Print</option> </select> <select name="actual" id= "actual"><option value="0"selected="selected">Design Only</option><option value="16">Design & Print</option></select>This is the droplist.js// JavaScript Documentfunction listSel(fld,id) {var opt = fld.selectedIndex;if (fld[opt].value != ' ') {var sel = document.getElementById(id);for (var i = sel.options.length -1; i > -1; i--) {if (fld[opt].value == sel.value) sel.selected = true;}}}

Link to comment
Share on other sites

you want the selected option of id="actual" to change to selected option of name="select" dropdown list? if so I can't see any problem it works just fine from what i can see.
thank you for the reply, at the moment it works fine but what I want is this please have a look:<select name="select" onchange="listSel(this,'actual')"><option value="0"selected="selected">Design Only</option><option value="16">Design & Print</option></select><select name="actual" id= "actual"><option value="Design Only"selected="selected">Design Only</option> CHANGED<option value="Design & Print">Design & Print</option> CHANGED</select>when changing the <option value= "Design Only" and "Design & Print" the script stops working, try it and see if it works
Link to comment
Share on other sites

well that because NOW! you are comparing value 0 and 16 with 'Design Only' and 'Design & Print' which won't match and therefore won't do anything.to continue to work it would now have to compare text between option tagsif (fld[opt].text == sel.text) sel.selected = true;

Link to comment
Share on other sites

well that because NOW! you are comparing value 0 and 16 with 'Design Only' and 'Design & Print' which won't match and therefore won't do anything.to continue to work it would now have to compare text between option tagsif (fld[opt].text == sel.text) sel.selected = true;
Thank you so much you have saved me allot of time, it works like a charm. Good man
Link to comment
Share on other sites

well that because NOW! you are comparing value 0 and 16 with 'Design Only' and 'Design & Print' which won't match and therefore won't do anything.to continue to work it would now have to compare text between option tagsif (fld[opt].text == sel.text) sel.selected = true;
I have modified the html part of the script, I have added server side ASP to it, please have a look once again if possible, as now its not working?? can you see what I am I doing wrong, the JS is still the same.<select name="select2" onchange="listSel(this,'actual2')"><option value="Poster Material"<%If (Not isNull((Recordset2.Fields.Item("Format").Value))) Then If "Poster Material" = CStr((Recordset2.Fields.Item("Format").Value)) Then Response.Write("selected=""selected""") : Response.Write("")%>>Poster Material</option><option value="Banner Material 500uc"<%If (Not isNull((Recordset2.Fields.Item("Format").Value))) Then If "Banner Material 500uc" = CStr((Recordset2.Fields.Item("Format").Value)) Then Response.Write("selected=""selected""") : Response.Write("")%>>Banner Material 500uc</option> </select><select name="actual2" id="actual2"><option value="190"<%If (Not isNull((Recordset2.Fields.Item("Format").Value))) Then If "Poster Material" = CStr((Recordset2.Fields.Item("Format").Value)) Then Response.Write("selected=""selected""") : Response.Write("")%>>Poster Material</option><option value="190"<%If (Not isNull((Recordset2.Fields.Item("Format").Value))) Then If "Banner Material 500uc" = CStr((Recordset2.Fields.Item("Format").Value)) Then Response.Write("selected=""selected""") : Response.Write("")%>>Banner Material 500uc</option></select>
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...