JavaScript - Selectbox Show Input Filed
Hello,
I have this code: PHP Code: <script> function checkForOther(obj) { if (!document.layers) { var txt = document.getElementById("otherTitle"); if (obj.value == "new") { txt.style.display = "inline"; // gives the text field the name of the drop-down, for easy processing txt.name = "selTitle"; obj.name = ""; } else { txt.style.display = "none"; txt.name = ""; obj.name = "selTitle"; } } } </script> it's should hide/show input field accourding the user choice - if he choose "<option value='new'>new</option>", the follow action should happend: PHP Code: <li id='otherTitle'> <label for='new'>new artist</label> <input type='text' name='new_artist_name' /> </li> The script works, but when I click "submit" the parameter that the "select box" should send don't get send... here is the full code: PHP Code: <li> <label for='artist'>Artists</label> <select name='artist_id' onchange="checkForOther(this)\"> <option value='new'>new artist</option>"; $query = mysql_query("SELECT id, name FROM `chords_artists` ORDER BY `name` "); while($index = mysql_fetch_array($query)) { $artist_id = $index['id']; $artist = $index['name']; echo "<option value='$artist_id'>$artist</option>"; } echo " </select> </li> <li id='otherTitle'> <label for='new'>new artist:</label> <input type='text' name='new_artist_name' /> </li> Can you please help me with it? Similar TutorialsI'm trying to figure out how to make a select box change which <div> should show or hide... Code: <script language="JavaScript"> function doHideShowMatchplayOptions(divName){ var objDiv = document.getElementById(divName); if(objDiv.style.display == ''){ objDiv.style.display = 'none } else { objDiv.style.display = ' } } </script> <select name="matchplaytype" onchange="doHideShowMatchplayOptions(\'idHideShowMatchplayOptions\');"> <option value="">Choose</option> <option value="1"># 1</option> <option value="2"># 2</option> </select> <div id="idHideShowMatchplayOptions" style="display:none;"> <table><tr><td colspan="2">This is # 1</td></tr></table> </div> <div id="idHideShowMatchplayOptions" style="display:none;"> <table><tr><td colspan="2">This is # 2</td></tr></table> </div> In the above script I'm only able to change one div... What I want is to be able to, if a user changes the selectbox from "# 1" to "# 2", to change the viewable div.... Hope this makes sense and somebody can help... THanks in advance :-) My code (below) currently has a Table with 3 columns, each with a different selectBox. I wish to have just one cell with a changing selectBox. Initial state: Only the citySelectBox should display. (this is currently in the first column of the table) State2: If user selects <option value='-1'>[-- change country --]</option> then the countrySelectBox should appear. (This is currently in the second column of the table) State 3: On click of the countrySelectBox, the cityDiv (id='ctWrapper') should display. This is currently in the third column of the table) Note: The commented-out code has a text link. OnClick opens up the countrySelectBox, but I don't want a text link. I want the user to use the <option value='-1'>[-- change country --]</option> Haven't a clue how to do any of this Any help out there? New Kid On The Block Code: <script type="text/javascript"> <!-- function loadCities(countryID){ if(countryID == "") { displayCities(""); return; } var contentLoader = new ylib.util.ContentLoader(this,"/ajax/citiesServer.asp?c=" + countryID,cityCallback,null); //var x = req.send("GET",,"",null,null,false,countryID,cityCallback,null); contentLoader.SendRequest(); } function cityCallback(request){ displayCities(request.responseText); } function displayCities(cityOptions) { var citySelect = xGetElementById('ct'); xDisplay(citySelect,'block'); var cityDiv = xGetElementById('ctWrapper'); var selectBox = ""; if(cityOptions != "") { selectBox = "<select name='ct' id='ct' onchange='this.form.submit();'><option value=''>-- select city --</option>" + cityOptions + "</select>"; } cityDiv.innerHTML = selectBox; } --> </script> <table align="right" border="0"> <tr> <%If Instr(sUrl, "city.asp") Then%> <td> <form name="citySelect" method="GET" action="../en/city.asp" onsubmit="alert('submit to default page');return false;"> <select name="ct" id="ct" onchange="submit()"> <option value=''>-- change city --</option> <option value='-1'>[-- change country --]</option> <%=list_CityOptions("")%> </select> </form> </td> <%End If%> <!-- <td> <a style="padding-left:8px;font-size:12px;text-decoration:none;" href="javascript:void(0);" onclick="this.style.display='none';<%If Instr(sUrl, "city.asp") Then%>citySelect.style.display='none';<%End IF%>xDisplay('locationSelection','block');">change country</a> </td> --> </tr></table> <div id="locationSelection" style="float:right; display:none;"> <form method="GET" action="../en/city.asp" onsubmit="alert('submit to default page');return false;"> <th> <select name='c' onchange='loadCities(this.options[this.selectedIndex].value);'> <option value="">-- select country --</option> <option value="1">Israel</option> <option value="63">USA - Central</option> <option value="2">USA - North East</option> <option value="61">USA - South East</option> <option value="62">USA - West</option> <option value="3">United Kingdom</option> <option value="4">South Africa</option> <%=list_DefaultCountryOptions("")%> </select> </th> <th> <p id='ctWrapper'></p> </th> </tr> </table> </form> In my website i have many articles... URL of each article is like below http://www.mysite.com/article/1 http://www.mysite.com/article/2 http://www.mysite.com/article/3 http://www.mysite.com/article/4 Etc... So each article got a number in the URL >>>>> What I need now is <<<<<< To make little form with only 1 filed in main page Filed is to add the article number... Then by submitting the form the URL of article will open For example: If I enter number 4 and click submit That will open URL http://www.mysite.com/article/4 Thank you This code works to show divide with id "it" when select option "it" is chosen and it shows divide "de" when option "de" is chosen. Problem: it will not show the nested divides inside the "it" and "de" divides. It only shows the <p></p> tags. Does someone know how I can get it to show the divides inside the main divide as well? Thanks in advance for your help. Head Code: function showstuff(divID) { els = document.getElementById( 'mydiv' ).getElementsByTagName( 'div' ); for (var i = 0; i < els.length; i++) { els[i].style.visibility="hidden"; els[i].style.display="none"; } if( divID ) { document.getElementById(divID).style.visibility="visible"; document.getElementById(divID).style.display="block"; } if( window.event ) window.event.returnValue = false; return false; } window.onload=function() { showstuff(''); } Body Code: <select size="1" hide_label="0" id="experience" class=" validate['required']" title="" type="select" name="experience" onchange="showstuff(this.value) ;"> <option value="">(Please select)</option> <option value="it">IT</option> <option value="de">Design Engineer</option> <option value="both">BOTH</option> </select> <div id="mydiv"> <div id="it"> <p>why dont you show anything else!</p> <div class="ccms_form_element cfdiv_header" id="_h3_it_disciplines_check_all_that_apply_h3___container_div"><h3>IT Disciplines (Check all that apply)</h3><div class="clear"></div></div> </div> <div id="de"> <p>why dont you show anything else! UGH!!</p> <div class="ccms_form_element cfdiv_header" id="_h3_design_engineer_disciplines_check_all_that_apply_h3___container_div"><h3>Design Engineer Disciplines (Check all that apply)</h3><div class="clear"></div></div> <p>why dont you show anything else!</p> </div> </div> Hi, please help. I've been trying to check what I did wrong in my code but still the total doesn't show. Below is my javascript function: Code: function CalculateTotal(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r) { var tota= document.getElementById('a'); var totb= document.getElementById('b'); var totc= document.getElementById('c'); var totd= document.getElementById('d'); var tote= document.getElementById('e'); var totf= document.getElementById('f'); var totg= document.getElementById('g'); var toth= document.getElementById('h'); var toti= document.getElementById('i'); var totj= document.getElementById('j'); var totk= document.getElementById('k'); var totl= document.getElementById('l'); var totm= document.getElementById('m'); var totn= document.getElementById('n'); var toto= document.getElementById('o'); var totp= document.getElementById('p'); var totq= document.getElementById('q'); var totr= document.getElementById('r'); var grandTotal = tota + totb +totc + totd + tote + totf + totg + toth + toti +totj + totk + totl + totm + totn + toto + totp +totq + totr; document.getElementById('Total').value = grandTotal.toFixed(2); } Below is my textbox where there are more than 10 textboxes for user to enter donation amount. I'd like to calculate all the donation amount entered then show total in the bottom. Code: <fieldset id="fieldset-in_registration"> <table> <tr> <td style="width:390px;text-align:left"><label for="a" style="font-weight:bold">A. Aloha United Way Community Care Fund </label></td> <td style="float:right"> <input id="a" name="a" class="text" type="text" value="$<?php safeEcho($form['a'])?>" style="width:100px;" onChange="CalculateTotal()" /> <?php helper_error('a');?> </td> </tr> <tr> <td style="width:390px;text-align:left"><label for="b">211 Information and Referral Services </label></td> <td style="float:right"> <input id="b" name="b" class="text" type="text" value="$<?php safeEcho($form['b'])?>" style="width:100px;" onChange="CalculateTotal()" /> <?php helper_error('b');?> </td> </tr> <tr> <td style="width:390px;text-align:left"><label for="c">Volunteer Hawaii/Gifts-in-Kind</label></td> <td style="float:right"> <input id="c" name="c" class="text" type="text" value="$<?php safeEcho($form['c'])?>" style="width:100px;" onChange="CalculateTotal()"/> <?php helper_error('c');?> </td> </tr> </table> </fieldset> <fieldset id="fieldset-in_registration"> <label for="impact" style="font-weight:bold">B. Impact Areas</label> <table> <tr> <td style="width:390px;text-align:left"><label for="d">Crime and Drug Use</label></td> <td style="float:right"> <input id="d" name="d" class="text" type="text" value="$<?php safeEcho($form['d'])?>" style="width:100px;" onChange="CalculateTotal()"/> <?php helper_error('d');?> </td> </tr> <tr> <td style="width:390px;text-align:left"><label for="e">Early Childhood Development</label></td> <td style="float:right"> <input id="e" name="e" class="text" type="text" value="$<?php safeEcho($form['e'])?>" style="width:100px;" onChange="CalculateTotal()" /> <?php helper_error('e');?> </td> </tr> <tr> <td style="width:390px;text-align:left"><label for="f">Emergency and Crisis Services</label></td> <td style="float:right"> <input id="f" name="f" class="text" type="text" value="$<?php safeEcho($form['f'])?>" style="width:100px;" onChange="CalculateTotal()" /> <?php helper_error('f');?> </td> </tr> <tr> <td style="width:390px;text-align:left"><label for="g" >Financial Stability and Independence</label></td> <td style="float:right"> <input id="g" name="g" class="text" type="text" value="$<?php safeEcho($form['g'])?>" style="width:100px;" onChange="CalculateTotal()"/> <?php helper_error('g');?> </td> </tr> <tr> <td style="width:390px;text-align:left"><label for="h" >Homelessness</label></td> <td style="float:right"> <input id="h" name="h" class="text" type="text" value="$<?php safeEcho($form['h'])?>" style="width:100px;" onChange="CalculateTotal()"/> <?php helper_error('h');?> </td> </tr> </table> </fieldset> <fieldset id="fieldset-in_registration"> <p>D. <b>Agency/Program Support ($48 MINIMUM PER CHOICE)</b></p> <p>My gift is designated to one or more specific agencies or programs. Processing fee may apply. <p style="color:#FF0000">(Note: Agency Name is intentionally shorten/cut-off and indented to the next line to fit in the page. Choose either one of the indented line will give the same code.)</p> <div class="formfield"> <table> <tr> <td> <select id="designation_list1" name="designation_list1" size="1" style="overflow-x:scroll; width:390px; "> <?php foreach ($designation_list as $descode => $prompt) : ?> <option value="<?php echo $descode; ?>" ><?php safeEcho($descode); ?> </option> <?php endforeach; ?> </select> </td> <td> <input id="i" name="i" class="text" type="text" value="$<?php safeEcho($form['i'])?>" style="width:100px;" onChange="CalculateTotal()""/> </td> </tr> <tr> <td> <select id="designation_list2" name="designation_list2" size="1" style="overflow-x:scroll; width:390px; "> <?php foreach ($designation_list as $descode => $prompt) : ?> <option value="<?php echo $descode; ?>" ><?php safeEcho($descode); ?> </option> <?php endforeach; ?> </select> </td> <td> <input id="j" name="j" class="text" type="text" value="$<?php safeEcho($form['j'])?>" style="width:100px;" onChange="CalculateTotal();"/> </td> </tr> <tr> <td> <select id="designation_list3" name="designation_list3" size="1" style="overflow-x:scroll; width:390px; "> <?php foreach ($designation_list as $descode => $prompt) : ?> <option value="<?php echo $descode; ?>" ><?php safeEcho($descode); ?> </option> <?php endforeach; ?> </select> </td> <td> <input id="k" name="k" class="text" type="text" value="$<?php safeEcho($form['k'])?>" style="width:100px;" onChange="CalculateTotal()"/> </td> </tr> <tr> <td> <select id="designation_list4" name="designation_list4" size="1" style="overflow-x:scroll; width:390px; "> <?php foreach ($designation_list as $descode => $prompt) : ?> <option value="<?php echo $descode; ?>" ><?php safeEcho($descode); ?> </option> <?php endforeach; ?> </select> </td> <td> <input id="l" name="l" class="text" type="text" value="$<?php safeEcho ($form['l'])?>" style="width:100px;" onChange="CalculateTotal()"/> </td> </tr> <tr> <td> <select id="designation_list5" name="designation_list5" size="1" style="overflow-x:scroll; width:390px; "> <?php foreach ($designation_list as $descode => $prompt) : ?> <option value="<?php echo $descode; ?>" ><?php safeEcho($descode); ?> </option> <?php endforeach; ?> </select> </td> <td> <input id="m" name="m" class="text" type="text" value="$<?php safeEcho($form['m'])?>" style="width:100px;" onChange="CalculateTotal();"/> </td> </tr> <tr> <td> <select id="designation_list6" name="designation_list6" size="1" style="overflow-x:scroll; width:390px; "> <?php foreach ($designation_list as $descode => $prompt) : ?> <option value="<?php echo $descode; ?>" ><?php safeEcho($descode); ?> </option> <?php endforeach; ?> </select> </td> <td> <input id="n" name="n" class="text" type="text" value="$<?php safeEcho($form['n'])?>" style="width:100px;" onChange="CalculateTotal()"/> </td> </tr> <tr> <td> <select id="designation_list7" name="designation_list7" size="1" style="overflow-x:scroll; width:390px; "> <?php foreach ($designation_list as $descode => $prompt) : ?> <option value="<?php echo $descode; ?>" ><?php safeEcho($descode); ?> </option> <?php endforeach; ?> </select> </td> <td> <input id="o" name="o" class="text" type="text" value="$<?php safeEcho($form['o'])?>" style="width:100px;" onChange="CalculateTotal()"/> </td> </tr> <tr> <td> <select id="designation_list8" name="designation_list8" size="1" style="overflow-x:scroll; width:390px; "> <?php foreach ($designation_list as $descode => $prompt) : ?> <option value="<?php echo $descode; ?>" ><?php safeEcho($descode); ?> </option> <?php endforeach; ?> </select> </td> <td> <input id="p" name="p" class="text" type="text" value="$<?php safeEcho($form['p'])?>" style="width:100px;" onChange="CalculateTotal()"/> </td> </tr> <tr> <td> <select id="designation_list9" name="designation_list9" size="1" style="overflow-x:scroll; width:390px; "> <?php foreach ($designation_list as $descode => $prompt) : ?> <option value="<?php echo $descode; ?>" ><?php safeEcho($descode); ?> </option> <?php endforeach; ?> </select> </td> <td> <input id="q" name="q" class="text" type="text" value="$<?php safeEcho($form['q'])?>" style="width:100px;" onChange="CalculateTotal()"/> </td> </tr> <tr> <td> <select id="designation_list10" name="designation_list10" size="1" style="overflow-x:scroll; width:390px; "> <?php foreach ($designation_list as $descode => $prompt) : ?> <option value="<?php echo $descode; ?>" ><?php safeEcho($descode); ?> </option> <?php endforeach; ?> </select> </td> <td> <input id="r" name="r" class="text" type="text" value="$<?php safeEcho($form['r'])?>" style="width:100px;" onChange="CalculateTotal()"/> </td> </tr> <tr> <td style="text-align:right;"><b>TOTAL GIFT(S) DESIGNATED (A-D)</b><BR /> (Must not exceed donation amount)</td> <td><input name="Total" id="Total" type="text" maxlength="10" readonly="true" onChange="CalculateTotal(this.value)" /></td> </tr> </table> Please help. I tried for how many days using the javascript calculations and still didn't work. I have a form with the same calculations and it does work but this one doesn't. Please help. Thanks a lot. Hope to hear from you soon. I've not really an idea how to do this. I know how to do it in PHP, but I need it dynamic <input type="checkbox" name="facebook" value="1" /> if($_POST['facebook'] == 1) echo "<input type='text' name='facebook_url' />"; Could someone tell me how I should do this. Thanks. As you can see the above warning will be only shown when there is an error while inserting the data into the login form. Now I have tried to achieve it by: Hiding the div say "warning". Use a javascript while submitting the form to check for input validation. If found any error, the hidden div "warning" will show above the form as shown as in the image. I have tried it in Edit fiddle - JSFiddle Ples help Hi ya all, how can I show / hide the content of sub divs based on whether the input is != or = and be able to repeat this. I tried to hide the sub divs using , onclick if bla bla = '' ; Code: document.getElementById('hideme').innerHTML = ''; which works, but once I try to enter a new input, then nothing happens, even if the content of the sub divs is = input thx So I am trying to make a form that will eventually take the user to a specified link. It is a form that uses drop down menus. I based this off of someone elses code (with permission ), but it shows everything <= user input. I cannot for the life of me figure out how to make it only show only one of the next options. here is the JS code: Code: <script language="JavaScript"> function ShowMenu(num, menu, max) { for(i = 1999; i <= num; i++){ var menu2 = menu + i; document.getElementById(menu2).style.display = 'block'; } var num2 = num; num2++; while(num2 = max){ var menu3 = menu + num2; document.getElementById(menu3).style.display = 'none'; num2=num2+1; } } </script> This is only the JS code. I didn't want to waste space with the rest of the code. If you want to see it let me know and I can include that. I am sure this is rather basic, but my JS knowledge is less than that...It has been some time since undergrad computer science class. Thanks in advance for any help! Hi Guys i am a complete novice at ajax or javascript. I have been studying php for a while now and i know that, i am now starting php oop and that going well but i have never done anything like this. Anway i am creating a booking system which at the end of the process asks who supplied your voucher which they then select a supplier. The issue i have is my client wants it so if groupon is selected then an input text box should appear so that the user can input a security code from groupon. So basically it is Code: <select name="supplier" id="supplier"> <option value="">please select supplier</option> <option value="Groupon">Groupon</option> <option value="KGB Deals">KGB Deals</option> <option value="Other">Other</option> </select> So if value="Groupon" then Code: <input type="text" name="security" id="security" /> should appear next to it. Could someone please help me as the page cant refresh as it will lose its data which would have taken the user about 10 minutes to fill out Thanks in advance Hello, I am hoping someone can help me with following search form. As you can see I have created a form but I don't know how to fix the coding so when a user select a category it will add a different hidden filed for that option for example: When the user selects category "Men" the hidden filed Code: <INPUT TYPE="HIDDEN" NAME="REFERRER" VALUE="http://men.com/acatalog/"> will be added and when the user selects category "Kids" the hidden filed Code: <INPUT TYPE="HIDDEN" NAME="REFERRER" VALUE="http://kids.com/acatalog/"> will be added and so on... Here is my form coding I am using: Code: <form name="simplesearch" method="get" action="" onsubmit="ssite=document.getElementById('sitelist');this.action=ssite.options[ssite.selectedIndex].value;return true;"> <input type="hidden" name="page" value="search" /> <input type="hidden" name="PR" value="-1" /> <input type="hidden" name="TB" value="A" /> <input type="hidden" name="NOLOGIN" value="1" /><input align="top" class="main_search_box" name="SS" type="text" value="search for ..." onfocus="this.value='';"> Search within: <select id="sitelist"> <option value="">Select Catagory</option> <option value="http://kids.com/cgi-bin/ss000001.pl">kids</option> <option value="http://men.com/cgi-bin/ss000001.pl">men</option> <option value="http://women.com/cgi-bin/ss000001.pl">women</option> </select><input type="submit" class="button" name="ACTION" value="Go!"> </form> Also I have one more question how do I make the "Select Catagory" a Must Choose and if not chosen to give message that say"Please Select a Category" Thank you in advance for any help you can give me... I am a bigginer so please go easy on me Hi there, i'm new in the forum and need some help. I'm using wordpress to make my website but i have a problem.. I'm making a tags-menu in wordpress and call it in php with this function: PHP Code: <?php $items = wp_get_nav_menu_items('tags-menu'); //var_dump($items); echo "<select id='designfields' name='designfields'>"; foreach ($items as $list){ if($list->menu_item_parent != "0"){ echo "<option value=".$list->url."> ".$list->title."</option>"; } else { echo "<option value=".$list->url.">".$list->title."</option>"; } } echo "</select>"; ?> this give me what i want: Code: <select id='designfields' name='designfields'> <option value=http://myweb.com.ar/portfolio/>All Fields</option> <option value=http://myweb.com.ar/tag/branding/>Branding</option> <option value=http://myweb.com.ar/tag/print-design/>Print Design</option> <option value=http://myweb.com.ar/tag/web-design/>Web Design</option> <option value=http://myweb.com.ar/tag/ui-design/>UI Design</option> <option value=http://myweb.com.ar/tag/motion-graphics/>Motion Graphics</option> <option value=http://myweb.com.ar/tag/illustration/>Illustration</option> </select> I want to style this with css so i use the plugin jquery.selectbox, but when i style my menu with this plugin i lose the functionality, i need to convert this optionvalues in links like function onChange (a jumpmenu). so i think the problem is in the jquery.selectbox.js in some place must transform optionvalue in link. Here is the jquery.selectbox im using: https://github.com/claviska/jquery-s...y.selectBox.js Need some help with this, thanks Hi All, I am a newbie to Javascript, I have a text box which when searched with 3 characters of vendor name will do ajax request and populate the results below the textbox, beside the box are two arrows pointing to a selectbox, when i clcik on the right arrow after the search the vendor name should to added to the select box.... similarly after i add required vendor names, I should be able to delete the name from the select box. I have completed the ajax search part of the textbox, and I am stuck with the passing value to the selectbox portion. Anyhelp will be appreciated. thanks in advance! I currently have two selectbox, the first for categories and the second for subcategories. When an option from the category selectbox is chosen I would like the subcategory selectbox to be filled with options drawn from an array. The following code I have works for Chrome and Firefox but not in IE, I would appreciate any help to fix the code or new code which does a similar function. HTML: Code: <select size="9" id="category" name="category" onclick="return categoryChange();"> <option>Antiques ></option> <option>Art and Crafts ></option> </select> <select style="visibility:hidden" id="subcategory" name="subcategory" size="9"> </select> JAVASCRIPT: Code: function addOption(selectbox,text,value){ var optn = document.createElement("OPTION"); optn.text = text; optn.value = value; selectbox.options.add(optn); } var antiques = new Array("Furniture","Ceramics","Glass"); var art = new Array("Drawings and Paintings","Photographs"); function categoryChange(){ document.getElementById("subcategory").style.visibility = "visible"; document.getElementById("subcategory").innerHTML = ""; if(document.getElementById("category").value == "Antiques >"){ for (var i=0; i < antiques.length;++i){ addOption(document.myForm.subcategory, antiques[i], antiques[i]); } } else if(document.getElementById("category").value == "Art and Crafts >"){ for (var i=0; i < art.length;++i){ addOption(document.myForm.subcategory, art[i], art[i]); } } } Hi, I have a select box whose options are populated from an xml file, the code goes like this: Code: var sel_html = '<select onChange="handleSelected(this)">' + '<option selected> - Select a zone - <\/option>'; var a = 0; function createPolygon(pts,colour,name) { var shape = new GPolygon(pts,"#000000",1,1,colour,0.5, {title:name}); gpolygons[a] = shape; // ======= Add the entry to the select box ===== sel_html += '<option> ' + name + '<\/option>'; // ========================================================== a++; return shape; } // ======= This function handles selections from the select box ==== // === If the dummy entry is selected, the info window is closed == function handleSelected(opt) { for (var a=0; a<gpolygons.length; a++) { gpolygons[a].hide(); } var a = opt.selectedIndex - 1; if (a > -1) { gpolygons[a].show() } } sel_html += '<\/select>'; document.getElementById("selection").innerHTML = sel_html; which works fine for showing one option at a time, but what I would like to do is have one of the selections to be to show all of the options at the same time. At the moment I have it working with a checkbox that works off a separate piece of code, but it would be great to have that option within the select box. You can see the select box in question here - it's the one on the right which says "Select a zone" thanks in advance. Hello there !! I really hope someone can help me out with this.. ( im stuck for about 5 hours all ready!! ) most likely because im not so good in javascript...... I want to show multiple divs on select of a <option> box. So lets say there are 3 options Code: <select name="hoofd_pakket" onchange="showDivs('div',this)"> <option value="a">Alles in 1</option> <option value="b">Internet + TV</option> <option value="c">Internet + Bellen</option> </select> And a javascript function to show the div`s Code: function showDivs(prefix,chooser) { for(var i=0;i<chooser.options.length;i++) { var div = document.getElementById(prefix+chooser.options[i].value); div.style.display = 'none'; } var selectedvalue = chooser.options[chooser.selectedIndex].value; if(selectedvalue == "a") { displayDivs(prefix,"a"); displayDivs(prefix,"c"); displayDivs(prefix,"d"); } if(selectedvalue == "b") { displayDivs(prefix,"b"); displayDivs(prefix,"c"); } if(selectedvalue == "c") { displayDivs(prefix,"d"); } } function displayDivs(prefix,suffix) { var div = document.getElementById(prefix+suffix); div.style.display = 'block'; } And some divs to show Code: <div id="diva" style="display:none;">blabla</div> <div id="divb" style="display:none;">blabla</div> <div id="divc" style="display:none;">blabla</div> <div id="divd" style="display:none;">blabla</div> All works fine up to some point, when I choose lets say option 'b' first.. I get 2 divs. Thats good.. Then I choose option 'c' I get only one div. Thats good.. But if I choose option 'b' again, I get 3 divs instead of 2 !! It shoudnt show the div from from option 'c'.. Does anybody understand why?? Thanx allot !!! Hi, I'm trying to write a function that will show arrowheads on polylines selected from a select box in a google map. I only want the arrowheads that belong to the line shown to be displayed. I have got it working using check boxes, and the select box shows the lines, but am having trouble tweaking the code to get the arrows to show up as well. You can see the working checkboxes (and the semi-working selectbox) he http://www.xelawho.com/map/zonesarrowstest.htm I see the error at line 135 ("Cannot read property 'onclick' of undefined") which I assume refers to the option, but this is where my limited js understanding begins to falter... how do I define the option if the select box options come from xml? And will defining it actually make this code work? Below are (what I think are) the relevant bits of code. Thanks in advance for any help. (cross-posted on the google maps forum and here over the last few days, but unanswered) Code: var h = 0; var v = 0; // === Function to create a marker arrow === function createArrow(point,icon,category) { var arrows = new GMarker(point,icon); map.addOverlay(arrows); pts[v] = arrows; arrows.hide(); arrows.mycategory = category; pts.push(arrows); } var select_html = '<select onChange="handleSelected2(this)">' + "selclick(this)" + '<option selected> - Select a bus route - <\/option>'; function showsel(category) { for (var v=0; v<pts.length-1; v++) { if (pts[v].mycategory == category) { pts[v].show(); } } document.getElementById(category+"option").onclick = true; } function hidesel(category) { for (var v=0; v<pts.length-1; v++) { if (pts[v].mycategory == category) { pts[v].hide(); } } } function selclick(option,category) { if (option.onclick) { showsel(category); } else { hidesel(category); } } function handleSelected2(opt,category) { for (var h = 0; h <gpolylines.length; h++) { gpolylines[h].hide(); } var h = opt.selectedIndex - 1; if (h > -1) { gpolylines[h].show(); } for (var v=0; v<pts.length; v++) { selclick(category); } } GDownloadUrl("allzonesencoded.xml", function(doc) { var xmlDoc = GXml.parse(doc); var lines = xmlDoc.documentElement.getElementsByTagName("line"); for (var i=0; i< pts.length; i++) { var category = lines[a].getAttribute("category"); } // ===== final part of the select box ===== select_html += '<\/select>' ; document.getElementById("selection2").innerHTML = select_html; Hello. I am asking this question in the "javascript" forum as my"select box" does use javascript. (Maybe it is actually called a List menu)? It is probably a simple question. If you look at the link to my example, you will see that my selectbox only displays the first line of the list (which says "select one"). For reasons, I will not be putting images or anything in the blue area, so wish there is a way to have like the first 20 or so selections visible, so I do not have just a big blue box sitting there. I didn't know if there was a way to do this? I appreciate any advice. Thank you. Buffmin My link is: http://test.cnjwebsolutions.com/ I am thinking this should be fairly easy but yet I am not getting far. I want to have a form with a single text imput field for a zip code. Depending on which zip code the user enters will determine which url they will be sent to. If they enter a zip code which is not in the script, they would be sent to a default url. I am also assuming this can be accomplished with javascript. Any help is greatly appreciated. I have a problem with adding new inputs to a form (if and when required), Internet Explorer is fine but in Firefox if any previous input fields are filled when the more button is clicked they get reset to blank. JS: Code: fields = 0; function addInput() { if (fields != 100) { document.getElementById('input').innerHTML += "<input type='text' name='input[]' size='30' />"; fields += 1; } else { document.getElementById('input').innerHTML += "<br />Maximum 100 fields allowed."; document.form.add.disabled=true;} } form: Code: <form action="index.php" method="post"> <div id="input"> <input type="text" name="input[]" size="30" maxlength="15" /> </div> <!-- button --> <div id="more"> <input type="button" onclick="addInput()" name="add" value="More" /> </div> <!-- // button --> <input type="submit" name="submit" value="Submit" /> </form> as usual any help is appretiated .. |