Did you ask in http://jquerybox.com/index.php/topic,760.0.html ???
I had just answered you there! I had tested in FF and IE7. here are the code I used. Since my english is not that good, I hope I got what you wanted. <script> $(function(){ $('select').each(function(){ this.selectedIndex = 0; }); }); function redirect_to_url(url) { if(url!='') window.location = url ; } </script> <table> <thead> <th>Region</th> <th>Action</th> </thead> <tbody> <tr> <td><strong>001</strong></td> <td> <select id="form_action" onChange="redirect_to_url(this.value)"> <option>--Select--</option> <option value="http://abcd.cgi?value=001">abcd</option> <option value="http://xyz.cgi?value=001">xyz</option> <option value="http://lol.cgi?value=001">Lol</option> </select> </td> </tr> <tr> <td><strong>002</strong></td> <td> <select id="form_action" onChange="redirect_to_url(this.value)"> <option>--Select--</option> <option value="http://abcd.cgi?value=001">abcd</option> <option selected="selected" value="http://xyz.cgi? value=001">xyz</option> <option value="http://lol.cgi?value=001">Lol</option> </select> </td></tr> </tbody> </table> On Nov 17, 3:21 pm, ninadmhatre <ninad.mha...@gmail.com> wrote: > HI > I am very new to Java scripting. I am stuck at one html page which has 6 > <SELECT> blocks with same ID attribute and options in this <SELECT> blocks > are nothing but the links to different pages ( ALL LINKS ARE UNIQUE ) . > This page is dynamically generated by ( Template Toolkit ) so I can not > hardcode the ID. > > What i wanted is when user load the page all drop-downs will be at default > value "--select--" and when user selects any option from drop-down he gets > redirected to new page also when he comes back to same page ( via back > button on browser ) it again should be defaulted to "--select--" option. > > I managed to do what I wanted via JQuery, But the issue was It never worked > in IE ( worked fine in Firefox ) > Here is the code : > > $(document).ready(function(){ > $("select#form_action").change( function() { > var url = this.value ; > if ( url != '') > { > window.location = url ; > url = '' ; > $("select#form_action").val(''); > } > }) ; > }) ; > > Now this didn’t work so I changed <SELECT> block added onChange event and > called the function redirect_to_url but I was not able create my own > function in JQuery It never worked. > So I changed that part to Java script and it worked as expected but here the > issue was I needed to set all drop downs to default values ( --select--) > which I couldn’t do in java script. > Here is Java script : > > <script style='text/javascript'> > > function redirect_to_url(url) { > if ( url != '' ) > { > window.location = url ; > url = '' ; > $("select#form_action").val(''); > } > } > </script> > > So I reset that field using JQuery & other processing using Java script. It > working but I didn’t like it. Can some one provide me solution to my problem > or at least guide me ? > - Create a function in JQuery and call it via onChange event ? > Or > - Default the value of drop–down on page load. > > Here is Sample HTML I am using : > > <table> > <thead> > <th>Region</th> > <th>Action</th> > </thead> > <tbody> > <tr> > <td><strong>001</strong></td> > <td> > <select id="form_action" onChange="redirect_to_url(this.value)"> > <option>--Select--</option> > <option value="http://abcd.cgi?value=001">abcd</option> > <option value="http://xyz.cgi?value=001">xyz</option> > <option value="http://lol.cgi?value=001">Lol</option> > </select> > </td> > </tr> > > <tr> > <td><strong>002</strong></td> > <td> > <select id="form_action" onChange="redirect_to_url(this.value)"> > <option>--Select--</option> > <option value="http://abcd.cgi?value=001">abcd</option> > <option value="http://xyz.cgi?value=001">xyz</option> > <option value="http://lol.cgi?value=001">Lol</option> > </select> > </td></tr> > </tbody> > </table> > > -- > View this message in > context:http://old.nabble.com/JQuery-Java-script-Help-required-tp26385438s272... > Sent from the jQuery General Discussion mailing list archive at Nabble.com.