Nope, it still won't automatically show the div. =/ Any other suggestions? ________________________________
From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Alexandre Plennevaux Sent: 03 May 2007 15:53 To: jquery-en@googlegroups.com Subject: [jQuery] Re: Dropdown select value help try instead: if ($("#jobtype_row select").val() !=""){ ... ________________________________ From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Luc Pestille Sent: jeudi 3 mai 2007 14:50 To: jquery-en@googlegroups.com Subject: [jQuery] Re: Dropdown select value help The onchange select works, but the onload doesn't =/ Something to do with is(".selected") ? Thanks. if ($("#jobtype_row select").is(".selected")){ switch ($(this).val()){ case 'p': $("#dayrate_row").hide(); $("#salary_row").show(); break; case 'f': $("#salary_row").hide(); $("#dayrate_row").show(); break; default: $("#salary_row").hide(); $("#dayrate_row").hide(); break; } } $("#jobtype_row select").change(function(){ switch ($(this).val()){ case 'p': $("#dayrate_row").hide(); $("#salary_row").show(); break; case 'f': $("#salary_row").hide(); $("#dayrate_row").show(); break; default: $("#salary_row").hide(); $("#dayrate_row").hide(); break; } }); ________________________________ From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Alexandre Plennevaux Sent: 03 May 2007 14:40 To: jquery-en@googlegroups.com Subject: [jQuery] Re: Dropdown select value help this should work, no? you could of course make this much more code efficient by wrapping the switch case in a function. (did not test this code, but you get the idea) $(document).ready(function(){ // onLoad if ($("select#mySelect").is(".selected")){ switch ($(this).val()){ case 'a': $("div#a").show(); $("div#b").hide(); break; case 'b': $("div#a").hide(); $("div#b").show(); break; default: $("div#a").hide(); $("div#b").hide(); break; } } // onChange behavior $("select#mySelect").change(function(){ switch ($(this).val()){ case 'a': $("div#a").show(); $("div#b").hide(); break; case 'b': $("div#a").hide(); $("div#b").show(); break; default: $("div#a").hide(); $("div#b").hide(); break; } }); ________________________________ From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Luc Pestille Sent: jeudi 3 mai 2007 12:52 To: jquery-en@googlegroups.com Subject: [jQuery] Re: Dropdown select value help I think it's a bit clearer, but I don't think I want to use .change, because there might not be a change... It's better explained in code; <select> <option value=""></option> <option value="a">Ayyyye</option> <option value="b">Beeee</option> </select> <div id="a"></div> <div id="b"></div> div #a and #b are hidden at the start. When a user chooses "Ayyyye", div #a should show and div #b should hide, and vice versa. However, the select could be generated like this; <select> <option value=""></option> <option value="a">Ayyyye</option> <option value="b" selected="selected">Beeee</option> </select> and in this case, div #b should show itself without any change from the user. Does that help explain it more? ________________________________ From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Alexandre Plennevaux Sent: 03 May 2007 13:28 To: jquery-en@googlegroups.com Subject: [jQuery] Re: Dropdown select value help Hi luc, basically, with the few details you provide, i can only say that you will trigger things using the event "change" on the select element. From then on, use the select.val() example: $("select#type").change(function(){ if($(this).val()=='root'){ $("select#project_mode").val("none").Highlight(1000, '#FF0000'); }else { if ($("select#project_mode").val()=='none') { $("select#project_mode").val("").Highlight(1000, '#FF0000'); } } }); ________________________________ From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Luc Pestille Sent: jeudi 3 mai 2007 12:24 To: jquery-en@googlegroups.com Subject: [jQuery] Dropdown select value help Hi all, I've got a problem I can't work out on my own, so i thought I'd enlist the help of you lot =]. I have a dropdown select in a form in an admin system that is either auto selected, or changed by a user - dependent on what they select, or what is selected automatically, I want other <div>s to be visable. There's going to be something to do with .val() and .bind(), but it goes beyond me at that point. Any help would be appreciated. Thanks, Luc Pestille Web Designer e: [EMAIL PROTECTED] t: +44 (0)1628 899 700 f: +44 (0)1628 899 701 In2 Thames House Mere Park Dedmere Road Marlow Bucks SL7 1PB Tel 01628 899700 Fax 01628 899701 e: [EMAIL PROTECTED] i: www.in2.co.uk <http://www.in2.co.uk/> This message (and any associated files) is intended only for the use of jquery-en@googlegroups.com and may contain information that is confidential, subject to copyright or constitutes a trade secret. If you are not jquery-en@googlegroups.com you are hereby notified that any dissemination, copying or distribution of this message, or files associated with this message, is strictly prohibited. If you have received this message in error, please notify us immediately by replying to the message and deleting it from your computer. Messages sent to and from us may be monitored. Any views or opinions presented are solely those of the author [EMAIL PROTECTED] and do not necessarily represent those of the company. Ce message Envoi est certifié sans virus connu. Analyse effectuée par AVG. Version: 7.5.467 / Base de données virus: 269.6.2/785 - Date: 2/05/2007 14:16 Ce message Envoi est certifié sans virus connu. Analyse effectuée par AVG. Version: 7.5.467 / Base de données virus: 269.6.2/785 - Date: 2/05/2007 14:16 Ce message Envoi est certifié sans virus connu. Analyse effectuée par AVG. Version: 7.5.467 / Base de données virus: 269.6.2/785 - Date: 2/05/2007 14:16
<<in2-logo-small.gif>>