JavaScript - Dynamic Dropdown Form Loading
Hey,
Were I am stuck is with the jquery I have a form that is done in a form class and when an option is selected from the dynamically populated drop down menu I would like it to fill in the text boxes so they can be edited. I currently have: getfeed.php - the page that is connected to the javascript Code: <?php include('class/class.form.php'); include('class/class.users.php'); $iID = trim($_GET['extension']); if(!$iID) die('No User Data found.'); $getValues = new Extension(); $user_info = $getValues->getUsersInformation($iID); $sip_info = $getValues->getSipInformation($iID); //print_r($user_info); //print_r($sip_info); $array = $getValues->getUsersInformation($iID); echo '<br /><br />-- end of query --'; The Javascript Code: if(document.id('LoadExtension') && document.id('ExtensionResponse')) { // id of select box var sel = document.id('LoadExtension'); // ser select box as var. sel.addEvent('change', function(chg) { // add change event to select box. if(sel.getSelected().get('value') != '') { // on change if selected value is not empty. new Request.HTML({ url : 'http://Domain.co.nz/Air/includes/getFeed.php?extension='+ sel.getSelected().get('value'), onRequest: function() { document.id('ExtensionResponse').set('html', 'loading...'); }, onComplete: function(r1, r2, html, js) { document.id('ExtensionResponse').set('html', html); } }).send(); } }); } At the moment it does not load any data(I somehow need to get the $iID sent from the index.php but the drop down menu is a count array would I take it from this?) and is in a separate div below the form. Similar TutorialsHello, I have a rather complex problem involving ajax and the dynamic loading of text. Basically, I have a flash player with a video and a series of annotations that the customer would like to appear next to the flash player. These annotations need to dynamically light up and move as the timecode associated with the annotation is passed on the flash player's timecode. I had a basic static system up and running fine. The problem is that the videos could be 3 hours long and have thousands of annotations - which causes a looonng load time for the page so I would like them to appear dynamically. At the moment I have tried using the below code to load the first 100 annotations and then when the 100th annotation appears, the next 100 should load up. The trouble is that it doesn't work! The first 100 annotations cycle through perfectly but then nothing seems to happen when the 100th annotation is read. Please help! Here's the code.... On the record's html page, I load up the first 100 annotations in the $annotations array in a container called 'media-meta-container' - which appears next to the Flash plaer: Code: <div id="media-item" style="width: 858px;"> <div id="media-meta-container" style="width: 302px;"> <ul> <? $annotate_count = 0; ?> <? for($i=0;$i<10;$i++): ?> <? if($annotations[$i]["start"] > 0 && $annotations[$i]["end"] > 0): ?> <li class="media-meta-li-off" id="annotation_container_<?=$annotate_count?>" onclick="seekPrompt(<?=$annotations[$i]["start"]?>);"><p><?=$annotations[$i]["text"]?></p></li> <input type="hidden" id="start_<?=$annotate_count?>" value="<?=$annotations[$i]["start"]?>" /> <? $annotate_count++; ?> <? endif; ?> <? endfor; ?> </ul> </div> <input type="hidden" id="count" value="<?=$annotate_count?>" size="12" /> <input type="hidden" id="start_count" value="0" size="12" /> <input type="hidden" id="start_time" value="0" size="12" /> On an attached javascript file the following function is run every 100ms to update the annotations next to the player: Code: function updateTimeCode() { var player = document.FLVClipEditor; if (player) { var state = player.getState(); var time = player.getCurrentTime(); var start_count = document.getElementById("start_count").value; var start_time = document.getElementById("start_time").value; document.getElementById("annotation_container_" + start_count).className = 'media-meta-li-off'; var end_count = document.getElementById("count").value; if(state != "stopped") { if(time <= start_time) { for(k=0;k<start_count;k++) { var start = document.getElementById("start_" + k).value; if(time < start) break; } var start_count = k - 1; } if(start_count > 0) start_count--; for(i=start_count;i<end_count;i++) { var start = document.getElementById("start_" + i).value; document.getElementById("annotation_container_" + i).className = 'media-meta-li-off'; if(time < start) break; } //IF WE HAVE REACHED THE END OF THE AVAILABLE ANNOTATIONS THEN LOAD UP SOME MORE - THIS IS THE PART I AM HAVING PROBLEMS WITH //THE FUNCTION FIRES BUT NOTHING HAPPENS if(end_count == i) { var new_end_count = end_count + 50; document.getElementById("count").value = new_end_count; scroll_annotations(end_count, new_end_count); } document.getElementById("annotation_container_" + start_count).className = 'media-meta-li-off'; document.getElementById("annotation_container_" + i).className = 'media-meta-li-off'; if(i > 0) i--; if(i - start_count > 3) { document.getElementById("start_count").value = i; document.getElementById("start_time").value = document.getElementById("start_" + i).value; } var filled = document.getElementById("annotation_container_" + i); if(i == 0) { var end = document.getElementById("start_0").value; if(time > end) { filled.className = 'media-meta-li-on'; } } else { filled.className = 'media-meta-li-on'; } document.getElementById("media-meta-container").scrollTop = filled.offsetTop - 412; } } } Here is the scroll_annotations() code that is being called when we reach the end of the annotations: Code: function scroll_annotations(start, end){ $.ajax({ type: "GET", url: "/xml/record_annotations.php", dataType: "xml", data: "id="+id+"&media_urn="+media_urn+"&start="+start+"&end="+end+"", success: function(xml) { $(xml).find('annotation_item').each(function(){ var annotation_count = $(this).attr('id'); var startTimecode = $(this).find('startTimecode').text(); var start = $(this).find('start').text(); var annotate_count = $(this).find('annotate_count').text(); var text = $(this).find('text').text(); $('<li class="media-meta-li-off" id="annotation_container_' + annotate_count + '" onclick="seekPrompt(' + start +');"><p>' + text + '</p><p>' + startTimecode + '</p></li><input type="hidden" id="' + annotate_count+ '" value="' + start + '" />').appendTo('ul#annotations-list-items'); }); } }); } Where record_annotations produces an xml file like this to give the annotations variables: Code: <annotations> − <annotation_item id="0"> <start>64.760000</start> <annotate_count>0</annotate_count> <text> ahnfea </text> </annotation_item> − <annotation_item id="1"> <start>65.360000</start> <annotate_count>1</annotate_count> <text> we all seek. Two states for two </text> </annotation_item> − <annotation_item id="2"> <start>65.920000</start> <annotate_count>2</annotate_count> <text> people living in peace and security. </text> </annotation_item> − <annotation_item id="3"> <start>70.720000</start> <annotate_count>3</annotate_count> <text> The verbal gloves came off at an EU </text> </annotation_item> − <annotation_item id="4"> <start>73.680000</start> <annotate_count>4</annotate_count> <text> summit in Brussels as the French </text> </annotation_item> </annotations> Thank you. Let me know if there is any other information you need I'm working on my portfolio and I want to get content to load into my "middle" div upon clicking on the buttons in the sidebar. I'm able to get it to load, but I can't figure out how to get the CSS to load. I keep getting errors in the code. Here is the code I'm using: http://www.dynamicdrive.com/dynamici...jaxcontent.htm Here is what I've got: Code: <img src="images/rule.png" id="rule" width="1" height="1" /> <a href="javascript:ajaxpage('about.html', 'middle');"><img src="images/about.png" width="195" height="101" alt="about" /></a> <img src="images/rule.png" id="sidebar_rule" width="194" height="1" /> <a href="javascript:ajaxpage('work.html', 'middle');"><img src="images/work.png" width="195" height="101" alt="work" /> <img src="images/rule.png" id="sidebar_rule" width="194" height="1" /> <img src="images/resume.png" width="195" height="101" alt="resume" /> <img src="images/rule.png" id="sidebar_rule" width="194" height="1" /> <a href="javascript:ajaxpage('contact.html', 'middle'); loadobjs('contact.css', 'feature.js')"><img src="images/contact.png" width="195" height="101" alt="contact" /></a> <img src="images/rule.png" id="sidebar_rule" width="194" height="1" /></div> I'm working on the contact page right now, just trying to figure out how to get it to load properly. Here is a screenshot of what it's supposed to look like: https://skitch.com/jillianadriana/r7...itled-document I can't get it to load with the custom CSS. Hi, I am making a widget to work on any site, that means not my site, so I have no control of what other libraries are used on the page. Thats why I am loading my own jQuery libraries dynamically and then execute my own code. An issue I have that some sites are loading fine and all is working as expected, but some sites are executing the code 2 times. I have made a page dump and put on my own server, so I can replicate the issue better. GOOD: here is a page that works OK: (see the button that says: send these contact details and map to your mobile.) Code: http://test.plustest.info/suffolk/contact.html BAD: here is the page that shows the button I am trying to load 2 times: Code: http://test.plustest.info/cream.html As you can see the button appears 2 times, which is wrong... Even it shows 2 times, the popup appears just ok when you click on the button. Would anyone be able to check what can be wrong here? the code is in the: Code: <div id="now_send_it_wrapper"> so its easier to find. Any help would be much appreciated. Thanks, Vladas I have been searching everywhere and have found a few of articles available regarding dropdown menu.. couldnt get exactly what i wanted.. i am not really good at javascript, or even programing..am trying my best. anyway~ Here is what i want. something simple if there is more than 1 data entity (count>1) (Case 1), then execute 'select(drop down)' else (count <=1)(Case 2), then just show the data entity itself. (i dun even want the dropdown box to appear) as below screenshot or the attachment I have a script getting me the dropdown menu as below, i wanna modify this but not sure where to start... -------------------------------- <div id="abcdefg"> <form id="setLanguage" action="{$request_uri}" method="post"> <select name="selectlanguage" id="selectlanguage" onchange="setLanguage(this.value)"> {foreach from=$languages key=k item=language name="languages"} <option value="{$language.id_lang}" {if $language.iso_code == $lang_iso} selected {/if} >{$language.name} </option> {/foreach} </select> <input type="hidden" name="id_lang" id="id_lang" value=""/> </form> </div> -------------------------------- Really appreciate your help with modifying this. Please try not to give me a totally new script (i bet it will/may work better but i wouldnt be able to understand..:-( so no point...) Hi there, im new to the forum and currently in the process of building a website. Unfortunetly it needs a little javascript putting in and I dont know any javascript atall. So heres my problem: -------------------- I want 3 drop down menus where you change the top option, the middle menu updates (from a sql database), you change the middle option then the bottom option updates (again from the database). you select the 3rd option. it searches a database for the item matching all 3 entrys it displays the price all without reloading the page then you add the item to cart. ------------ Heres my site with fake data in the dropdowns: http://xeon.donov.co.uk/~blinky/?a=cat_sub&cid=3&f=A3 Howdy, So I have some javascript/html on one file (another.html) that I would like to split into two separate pages: home2.html cars.js If you view the code for home2.html everything works up until the model form box. That's where my problem lies. I can get the code to work on another.html but I'm splitting it up incorrectly in home2.html Help would be much appreciated. PS: If you are going to gripe at me for not using PHP or SQL to make things easier (for future updates to code) at least link me to something to learn from then insult me. another.html Code: <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script language="javascript" type="text/javascript"> function dropdownlist(list) { document.formname.subcategory.options.length=0; switch (list) { case "bmw": document.formname.subcategory.options[0]=new Option("Select Model",""); document.formname.subcategory.options[1]=new Option("3 Series"); document.formname.subcategory.options[2]=new Option("5 Series"); document.formname.subcategory.options[3]=new Option("Z Series"); break; case "buick": document.formname.subcategory.options[0]=new Option("Select Model",""); document.formname.subcategory.options[1]=new Option("Century"); document.formname.subcategory.options[2]=new Option("Lesabre"); document.formname.subcategory.options[3]=new Option("Park Avenue"); document.formname.subcategory.options[4]=new Option("Regal"); document.formname.subcategory.options[5]=new Option("Riveria"); break; case "cadillac": document.formname.subcategory.options[0]=new Option("Select Model",""); document.formname.subcategory.options[1]=new Option("Catera"); document.formname.subcategory.options[2]=new Option("Deville"); document.formname.subcategory.options[3]=new Option("El Dorado"); document.formname.subcategory.options[4]=new Option("Seville"); break case "chevrolet": document.formname.subcategory.options[0]=new Option("Select Model",""); document.formname.subcategory.options[1]=new Option("Astro"); document.formname.subcategory.options[2]=new Option("Blazer S 10"); document.formname.subcategory.options[3]=new Option("Camaro"); document.formname.subcategory.options[4]=new Option("Corvette"); document.formname.subcategory.options[5]=new Option("G2500"); document.formname.subcategory.options[6]=new Option("Lumina"); document.formname.subcategory.options[7]=new Option("Malibu"); document.formname.subcategory.options[8]=new Option("Monte Carlo"); document.formname.subcategory.options[9]=new Option("Suburban"); document.formname.subcategory.options[10]=new Option("Tahoe"); document.formname.subcategory.options[11]=new Option("Ventur"); break case "chrysler": document.formname.subcategory.options[0]=new Option("Select Model",""); document.formname.subcategory.options[1]=new Option("Town & Country"); document.formname.subcategory.options[2]=new Option("Cirrus"); document.formname.subcategory.options[3]=new Option("Concord"); document.formname.subcategory.options[4]=new Option("Sebring"); break; case "dodge-plymouth": document.formname.subcategory.options[0]=new Option("Select Model",""); document.formname.subcategory.options[1]=new Option("Avenger"); document.formname.subcategory.options[2]=new Option("Breeze"); document.formname.subcategory.options[3]=new Option("Caravan Voyager"); document.formname.subcategory.options[4]=new Option("Durango"); document.formname.subcategory.options[5]=new Option("Intrepeid"); document.formname.subcategory.options[6]=new Option("Ram Van 1500"); document.formname.subcategory.options[7]=new Option("Ram Van 2500"); case "ford": document.formname.subcategory.options[0]=new Option("Select Model",""); document.formname.subcategory.options[1]=new Option("Contour"); document.formname.subcategory.options[2]=new Option("Crown Victoria"); document.formname.subcategory.options[3]=new Option("E150"); document.formname.subcategory.options[4]=new Option("E250"); document.formname.subcategory.options[5]=new Option("E350"); document.formname.subcategory.options[6]=new Option("Escort"); document.formname.subcategory.options[7]=new Option("Expedition"); document.formname.subcategory.options[8]=new Option("Explorer"); document.formname.subcategory.options[9]=new Option("Freestar"); document.formname.subcategory.options[10]=new Option("Mustang"); document.formname.subcategory.options[11]=new Option("Taurus"); document.formname.subcategory.options[12]=new Option("Windstar"); break; case "gmc": document.formname.subcategory.options[0]=new Option("Select Model",""); document.formname.subcategory.options[1]=new Option("Jimmy S 15"); break; case "honda": document.formname.subcategory.options[0]=new Option("Select Model",""); document.formname.subcategory.options[1]=new Option("Accord"); document.formname.subcategory.options[2]=new Option("Civic"); document.formname.subcategory.options[3]=new Option("Passport"); break; case "isuzu": document.formname.subcategory.options[0]=new Option("Select Model",""); document.formname.subcategory.options[1]=new Option("Odyssey"); document.formname.subcategory.options[2]=new Option("Rodeo"); break; case "jeep": document.formname.subcategory.options[0]=new Option("Select Model",""); document.formname.subcategory.options[1]=new Option("Cherokee"); document.formname.subcategory.options[2]=new Option("Grand Cherokee"); document.formname.subcategory.options[3]=new Option("Wrangler"); break; case "lincoln": document.formname.subcategory.options[0]=new Option("Select Model",""); document.formname.subcategory.options[1]=new Option("Continental"); document.formname.subcategory.options[2]=new Option("Navigator"); document.formname.subcategory.options[3]=new Option("Stratus"); document.formname.subcategory.options[4]=new Option("Town Car"); break; case "mercedez": document.formname.subcategory.options[0]=new Option("Select Model",""); document.formname.subcategory.options[1]=new Option("M Class ML"); case "mercury": document.formname.subcategory.options[0]=new Option("Select Model",""); document.formname.subcategory.options[1]=new Option("Cougar"); document.formname.subcategory.options[2]=new Option("Grand Marquis"); document.formname.subcategory.options[3]=new Option("Mountaineer"); document.formname.subcategory.options[4]=new Option("Mystique"); document.formname.subcategory.options[5]=new Option("Sable"); document.formname.subcategory.options[6]=new Option("Villager"); break; case "mitsubishi": document.formname.subcategory.options[0]=new Option("Select Model",""); document.formname.subcategory.options[1]=new Option("Eclipse"); document.formname.subcategory.options[2]=new Option("Galant"); break; case "nissan": document.formname.subcategory.options[0]=new Option("Select Model",""); document.formname.subcategory.options[1]=new Option("200 SX"); document.formname.subcategory.options[2]=new Option("Altima"); document.formname.subcategory.options[3]=new Option("Maxima"); document.formname.subcategory.options[4]=new Option("Quest"); document.formname.subcategory.options[5]=new Option("Sentra"); case "oldsmobile": document.formname.subcategory.options[0]=new Option("Select Model",""); document.formname.subcategory.options[1]=new Option("Alero"); document.formname.subcategory.options[2]=new Option("Blazer"); document.formname.subcategory.options[3]=new Option("Cutlass"); document.formname.subcategory.options[4]=new Option("Eighty Eight"); document.formname.subcategory.options[5]=new Option("Silhouette"); break; case "pontiac": document.formname.subcategory.options[0]=new Option("Select Model",""); document.formname.subcategory.options[1]=new Option("Boneville"); document.formname.subcategory.options[2]=new Option("Firebird"); document.formname.subcategory.options[3]=new Option("Grand AM"); document.formname.subcategory.options[4]=new Option("Grand Prix"); document.formname.subcategory.options[5]=new Option("Sun Fire"); document.formname.subcategory.options[6]=new Option("Transport"); break; case "saturn": document.formname.subcategory.options[0]=new Option("Select Model",""); document.formname.subcategory.options[1]=new Option("Saturn"); break; case "toyota": document.formname.subcategory.options[0]=new Option("Select Model",""); document.formname.subcategory.options[1]=new Option("4 Runner"); document.formname.subcategory.options[2]=new Option("Avalon"); document.formname.subcategory.options[3]=new Option("Camry"); document.formname.subcategory.options[4]=new Option("Corolla"); document.formname.subcategory.options[5]=new Option("Solara"); break; case "volkswagen": document.formname.subcategory.options[0]=new Option("Select Model",""); document.formname.subcategory.options[1]=new Option("Jetta"); document.formname.subcategory.options[2]=new Option("New Bettle"); document.formname.subcategory.options[3]=new Option("New Golf"); document.formname.subcategory.options[4]=new Option("New Jetta"); document.formname.subcategory.options[5]=new Option("Passat"); break; } return true; } </script> </head> <title>Dynamic Drop Down List</title> <body> <form id="formname" name="formname" method="post" action="submitform.asp" > <table> <tr> <td>Make:</td> <td><select name="category" id="category" onchange="javascript: dropdownlist(this.options[this.selectedIndex].value);"> <option value="">Select Make</option> <option value="bmw">BMW</option> <option value="buick">Buick</option> <option value="cadillac">Cadillac</option> <option value="chevrolet">Chevrolet</option> <option value="chryler">Chrysler</option> <option value="dodge-plymouth">Dodge-Plymouth</option> <option value="ford">Ford</option> <option value="gmc">GMC</option> <option value="honda">Honda</option> <option value="isuzu">Isuzu</option> <option value="lincoln">Lincoln</option> <option value="mercedez">Mercedez</option> <option value="mercury">Mercury</option> <option value="mitsubishi">Mitsubishi</option> <option value="nissan">Nissan</option> <option value="oldsmobile">Oldsmobile</option> <option value="pontiac">Pontiac</option> <option value="saturn">Saturn</option> <option value="toyota">Toyota</option> <option value="volkswagen">Volkswagen</option> </select></td> </tr> <tr> <td align="right" valign="middle">Model: </td> <td align="left" valign="middle"><script type="text/javascript" language="JavaScript"> document.write('<select name="subcategory"><option value="">Select Sub-Category</option></select>') </script> <noscript><select name="subcategory" id="subcategory" > <option value="">Select Model</option> </select> </noscript></td> </tr> </table> </form> </body> </html> home2.html Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <head> <link href="index.css" rel="stylesheet" type="text/css"> <script type="text/javascript" src="cars.js"></script> </head> <body> <div id="wrapperLeft"> <div id="wrapperRight"> <div id="main"> <div id="columnLeft"> <div id="center"><h3></h3></div> </div> <div id="columnRight"> <div id="center"><h3></h3> </div> </div> <div id="columnCenter"> <div id="center"> <form id="carinfo" name="carinfo" method="post"> <!--action="?"--> <fieldset><legend>Legalization of Autmoibles</legend> <table> <tbody> <tr> <td>First Name:</td><td><input type="text" name="firstname" maxlength="30"></td> </tr> <tr> <td>Last Name:</td><td><input type="text" name="lastname" maxlength="30"></td> </tr> <tr> <td>Number:</td><td><input type="text" name="number" maxlength="20"></td> </tr> <tr> <td>Email:</td><td><input type="text" name="email" maxlength="35"></td> </tr> <tr> <td>City:</td><td><input type="text" name="city" maxlength="30"></td> </tr> <tr> <td>State:</td><td><select name="state" size="1"> <option selected value=""></option> <option value="AL">Alabama</option> <option value="AK">Alaska</option> <option value="AZ">Arizona</option> <option value="AR">Arkansas</option> <option value="CA">California</option> <option value="CO">Colorado</option> <option value="CT">Connecticut</option> <option value="DE">Delaware</option> <option value="FL">Florida</option> <option value="GA">Georgia</option> <option value="HI">Hawaii</option> <option value="ID">Idaho</option> <option value="IL">Illinois</option> <option value="IN">Indiana</option> <option value="IA">Iowa</option> <option value="KS">Kansas</option> <option value="KY">Kentucky</option> <option value="LA">Louisiana</option> <option value="ME">Maine</option> <option value="MD">Maryland</option> <option value="MA">Massachusetts</option> <option value="MI">Michigan</option> <option value="MN">Minnesota</option> <option value="MS">Mississippi</option> <option value="MO">Missouri</option> <option value="MT">Montana</option> <option value="NE">Nebraska</option> <option value="NV">Nevada</option> <option value="NH">New Hampshire</option> <option value="NJ">New Jersey</option> <option value="NM">New Mexico</option> <option value="NY">New York</option> <option value="NC">North Carolina</option> <option value="ND">North Dakota</option> <option value="OH">Ohio</option> <option value="OK">Oklahoma</option> <option value="OR">Oregon</option> <option value="PA">Pennsylvania</option> <option value="RI">Rhode Island</option> <option value="SC">South Carolina</option> <option value="SD">South Dakota</option> <option value="TN">Tennessee</option> <option value="TX">Texas</option> <option value="UT">Utah</option> <option value="VT">Vermont</option> <option value="VA">Virginia</option> <option value="WA">Washington</option> <option value="WV">West Virginia</option> <option value="WI">Wisconsin</option> <option value="WY">Wyoming</option> </select></td> </tr> <tr><td>Do you have the following:</td></tr> <tr><td><input type="checkbox" name="mandatory" value="license" /></td><td>Driver's License</td></tr> <tr><td><input type="checkbox" name="mandatory" value="title" /></td><td>Vehicle Title</td></tr> <tr><td><input type="checkbox" name="mandatory" value="receipt" /></td><td>Utility Receipt from Mexico showing recieving address</td></tr> <tr><td><input type="submit" value="Submit" /></td></tr> <tr><td>Make</td> <td> <select name="category" id="category" onchange="javascript: dropdownlist(this.options[this.selectedIndex].value);"> <option value="">Select Make</option> <option value="bmw">BMW</option> <option value="buick">Buick</option> <option value="cadillac">Cadillac</option> <option value="chevrolet">Chevrolet</option> <option value="chryler">Chrysler</option> <option value="dodge-plymouth">Dodge-Plymouth</option> <option value="ford">Ford</option> <option value="gmc">GMC</option> <option value="honda">Honda</option> <option value="isuzu">Isuzu</option> <option value="lincoln">Lincoln</option> <option value="mercedez">Mercedez</option> <option value="mercury">Mercury</option> <option value="mitsubishi">Mitsubishi</option> <option value="nissan">Nissan</option> <option value="oldsmobile">Oldsmobile</option> <option value="pontiac">Pontiac</option> <option value="saturn">Saturn</option> <option value="toyota">Toyota</option> <option value="volkswagen">Volkswagen</option> </select> </td> </tr> <tr> <td>Model:</td> <td> <script type="text/javascript" language="JavaScript"> document.write('<select name="subcategory"><option value="">Select Sub-Category</option></select>') </script></td> </fieldset> </form> </tbody> </table> </div> </div> </div> </div> </div> <div class="footer"> </div> </body> </html> --cars.js contained in next post-- Hi, im looking for some help figuring out how to achieve the following: i have an ecommerce site. on a product a customer can select attributes associated with that product (i.e colour, size, shape etc.). Each attriute is represented by a HTML select, containing the values allowed for that product. the problem comes when certain colours do not come in certain sizes. Say my product has the following: colours: red, yellow, blue size: small, medium, large shape: square, circle but there is no stock for red,medium and red,large. I need to dynamically remove medium + large when red is selected so they cannot be chosen from the select. This could apply for any combination of attributes. Also this is completely dynamic so there could be 2 attributes or 10 attributes, and changing one would need to cascade down the selects. i have posted the code at the bottom of the post. The js representation of what is selectable is an object, containing other objects, each object representing a variation and wether to show or not. i know this is a right mouthful to try and explain, its even hard to figure out how to do it! an example of what im trying to achieve is: http://www.bit-cart.com/online-store-front-live-demo/products/Mikes-Test-Product.html. I do have jquery available on my page if it helps. any ideas would be most appreciated! thanks mike HTML: Code: <select name='attribute_12' id='attribute_12' class='attribute-select'> <option value='166'>attribute_12 166</option> <option value='165'>attribute_12 165</option> <option value='171'>attribute_12 171</option> </select> <select name='attribute_10' id='attribute_10' class='attribute-select'> <option value='108'>attribute_10 108</option> <option value='110'>attribute_10 110</option> <option value='120'>attribute_10 120</option> <option value='148'>attribute_10 148</option> </select> <select name='attribute_19' id='attribute_19' class='attribute-select'> <option value='201'>attribute_19 201</option> <option value='202'>attribute_19 202</option> <option value='203'>attribute_19 203</option> </select> JS: Code: <script type="application/javascript"> var variants = { "304" : {"attrs":[171,108,201], "show":0}, "305" : {"attrs":[171,108,202], "show":1}, "306" : {"attrs":[171,108,203], "show":0}, "307" : {"attrs":[171,120,201], "show":1}, "308" : {"attrs":[171,120,202], "show":0}, "309" : {"attrs":[171,120,203], "show":1}, "310" : {"attrs":[171,148,201], "show":0}, "311" : {"attrs":[171,148,202], "show":1}, "312" : {"attrs":[171,148,203], "show":0}, "313" : {"attrs":[171,110,201], "show":1}, "314" : {"attrs":[171,110,202], "show":0}, "315" : {"attrs":[171,110,203], "show":1}, "316" : {"attrs":[166,108,201], "show":0}, "317" : {"attrs":[166,108,202], "show":1}, "318" : {"attrs":[166,108,203], "show":0}, "319" : {"attrs":[166,120,201], "show":1}, "320" : {"attrs":[166,120,202], "show":0}, "321" : {"attrs":[166,120,203], "show":1}, "322" : {"attrs":[166,148,201], "show":0}, "323" : {"attrs":[166,148,202], "show":1}, "324" : {"attrs":[166,148,203], "show":0}, "325" : {"attrs":[166,110,201], "show":1}, "326" : {"attrs":[166,110,202], "show":0}, "327" : {"attrs":[166,110,203], "show":1}, "328" : {"attrs":[165,108,201], "show":0}, "329" : {"attrs":[165,108,202], "show":1}, "330" : {"attrs":[165,108,203], "show":0}, "331" : {"attrs":[165,120,201], "show":1}, "332" : {"attrs":[165,120,202], "show":0}, "333" : {"attrs":[165,120,203], "show":1}, "334" : {"attrs":[165,148,201], "show":0}, "335" : {"attrs":[165,148,202], "show":1}, "336" : {"attrs":[165,148,203], "show":0}, "337" : {"attrs":[165,110,201], "show":1}, "338" : {"attrs":[165,110,202], "show":0}, "339" : {"attrs":[165,110,203], "show":1} } </script> Hi I have two drop down menus I want the first one has name of the folders and when change the other dropdown has names of the sub-folders of this folder i have the top folders at the first dropdown how can i have the subfolders at the second when change first? the problem is how to open folder if i have folders aaaaa has subfolders(1111,2222,2233) bbbbb has subfolders(3333,4422,2433) ccccc has subfolders(1131,2232,2532) and each folder has subfolders how can i have name of these subfolders when change the topfolders(aaaaa, bbbbb, ccccc) I have more than 1000 top folders and eachone have 10 subfolders already i have all topfolders at first dropdown ,i want to have subfolders at second automatic , any help?? Javascript novice here looking to create a dynamic dropdown based on date. It's a list of preset prices that will change each month to reflect a pro-rated system. Any thoughts/examples on how I would go about setting this up using javascript would be much appreciated. Thanks. Here's what I need: In September, the dropdown will display these prices Code: <option value="100">Product 1</option> <option value="150">Product 2</option> <option value="200">Product 3</option> In October, the dropdown will display these prices <option value="50">Product 1</option> <option value="100">Product 2</option> <option value="150">Product 3</option> hello, i am writing a script that will update a dropdown list based on the selection of a previous list. the script is run by a PHP script, so instead of posting the PHP, i will post an example client-side script. the hierachy is: category, sub category, brand (but sometimes there exists no sub category and the PHP script queries and adds brands instead) everything works correctly, except for one major issue: you can not change the selection of the third (brand) box this could be an easy fix for some coders, but i am not experienced in javascript and could really use some help. here is an example script, sorry it is so long Code: <script language="javascript"> function fillprodCat(){ // this function is used to fill the category list on load addOption(document.prodCatSubCatBrand_list.add_prodCat, "1", "HD Video"); addOption(document.prodCatSubCatBrand_list.add_prodCat, "2", "Components"); addOption(document.prodCatSubCatBrand_list.add_prodCat, "3", "Audiophiles"); addOption(document.prodCatSubCatBrand_list.add_prodCat, "4", "Speakers"); addOption(document.prodCatSubCatBrand_list.add_prodCat, "5", "Whole House Audio"); addOption(document.prodCatSubCatBrand_list.add_prodCat, "6", "Furniture"); addOption(document.prodCatSubCatBrand_list.add_prodCat, "7", "Accessories"); } function SelectprodSubCat(){ // on selection of category, this is called removeAllOptions(document.prodCatSubCatBrand_list.add_prodSubCat); if(document.prodCatSubCatBrand_list.add_prodCat.value == "1"){ document.prodCatSubCatBrand_list.add_prodSubCat.disabled=false; addOption(document.prodCatSubCatBrand_list.add_prodSubCat,"1", "HD Television"); addOption(document.prodCatSubCatBrand_list.add_prodSubCat,"2", "HD Projectors"); addOption(document.prodCatSubCatBrand_list.add_prodSubCat,"3", "Screens"); } if(document.prodCatSubCatBrand_list.add_prodCat.value == "2"){ document.prodCatSubCatBrand_list.add_prodSubCat.disabled=false; addOption(document.prodCatSubCatBrand_list.add_prodSubCat,"4", "Turntables"); addOption(document.prodCatSubCatBrand_list.add_prodSubCat,"5", "Receivers, amps & preamps"); addOption(document.prodCatSubCatBrand_list.add_prodSubCat,"6", "DVD & CD players"); } if(document.prodCatSubCatBrand_list.add_prodCat.value == "3"){ document.prodCatSubCatBrand_list.add_prodSubCat.disabled=true; addOption(document.prodCatSubCatBrand_list.add_prodSubCat,"0", "None"); } if(document.prodCatSubCatBrand_list.add_prodCat.value == "4"){ document.prodCatSubCatBrand_list.add_prodSubCat.disabled=true; addOption(document.prodCatSubCatBrand_list.add_prodSubCat,"0", "None"); } if(document.prodCatSubCatBrand_list.add_prodCat.value == "5"){ document.prodCatSubCatBrand_list.add_prodSubCat.disabled=true; addOption(document.prodCatSubCatBrand_list.add_prodSubCat,"0", "None"); } if(document.prodCatSubCatBrand_list.add_prodCat.value == "6"){ document.prodCatSubCatBrand_list.add_prodSubCat.disabled=false; addOption(document.prodCatSubCatBrand_list.add_prodSubCat,"8", "AV Furniture"); addOption(document.prodCatSubCatBrand_list.add_prodSubCat,"7", "Armchairs"); } if(document.prodCatSubCatBrand_list.add_prodCat.value == "7"){ document.prodCatSubCatBrand_list.add_prodSubCat.disabled=false; addOption(document.prodCatSubCatBrand_list.add_prodSubCat,"10", "Power Conditioning"); addOption(document.prodCatSubCatBrand_list.add_prodSubCat,"9", "Remote Controls"); addOption(document.prodCatSubCatBrand_list.add_prodSubCat,"11", "Mounts"); addOption(document.prodCatSubCatBrand_list.add_prodSubCat,"12", "Cables & Interconnects"); } } function SelectprodBrand(){ // ON selection of category, sub category, or brand this is called removeAllOptions(document.prodCatSubCatBrand_list.add_prodBrand); if(document.prodCatSubCatBrand_list.add_prodCat.value == "1"){ if(document.prodCatSubCatBrand_list.add_prodSubCat.value == "1"){ document.prodCatSubCatBrand_list.add_prodBrand.disabled=false; addOption(document.prodCatSubCatBrand_list.add_prodBrand,"1", "Hitachi"); addOption(document.prodCatSubCatBrand_list.add_prodBrand,"2", "JVC"); addOption(document.prodCatSubCatBrand_list.add_prodBrand,"3", "Panasonic"); addOption(document.prodCatSubCatBrand_list.add_prodBrand,"4", "Pioneer"); addOption(document.prodCatSubCatBrand_list.add_prodBrand,"5", "Samsung"); addOption(document.prodCatSubCatBrand_list.add_prodBrand,"6", "Sharp"); } if(document.prodCatSubCatBrand_list.add_prodSubCat.value == "2"){ document.prodCatSubCatBrand_list.add_prodBrand.disabled=false; addOption(document.prodCatSubCatBrand_list.add_prodBrand,"7", "Epson"); addOption(document.prodCatSubCatBrand_list.add_prodBrand,"8", "JVC"); } if(document.prodCatSubCatBrand_list.add_prodSubCat.value == "3"){ document.prodCatSubCatBrand_list.add_prodBrand.disabled=false; addOption(document.prodCatSubCatBrand_list.add_prodBrand,"9", "Da-Lite"); } } if(document.prodCatSubCatBrand_list.add_prodCat.value == "2"){ if(document.prodCatSubCatBrand_list.add_prodSubCat.value == "4"){ document.prodCatSubCatBrand_list.add_prodBrand.disabled=false; addOption(document.prodCatSubCatBrand_list.add_prodBrand,"10", "Music Hall Audio"); } if(document.prodCatSubCatBrand_list.add_prodSubCat.value == "5"){ document.prodCatSubCatBrand_list.add_prodBrand.disabled=false; addOption(document.prodCatSubCatBrand_list.add_prodBrand,"11", "Arcam"); addOption(document.prodCatSubCatBrand_list.add_prodBrand,"12", "Bose"); addOption(document.prodCatSubCatBrand_list.add_prodBrand,"13", "Integra"); addOption(document.prodCatSubCatBrand_list.add_prodBrand,"14", "Krell"); addOption(document.prodCatSubCatBrand_list.add_prodBrand,"15", "Pioneer"); } if(document.prodCatSubCatBrand_list.add_prodSubCat.value == "6"){ document.prodCatSubCatBrand_list.add_prodBrand.disabled=true; addOption(document.prodCatSubCatBrand_list.add_prodBrand,"", "None"); } } if(document.prodCatSubCatBrand_list.add_prodCat.value == "3"){ if(document.prodCatSubCatBrand_list.add_prodSubCat.value == "0"){ document.prodCatSubCatBrand_list.add_prodBrand.disabled=true; addOption(document.prodCatSubCatBrand_list.add_prodBrand,"", "None"); } } if(document.prodCatSubCatBrand_list.add_prodCat.value == "4"){ if(document.prodCatSubCatBrand_list.add_prodSubCat.value == "0"){ document.prodCatSubCatBrand_list.add_prodBrand.disabled=false; addOption(document.prodCatSubCatBrand_list.add_prodBrand,"16", "Canton"); addOption(document.prodCatSubCatBrand_list.add_prodBrand,"17", "Dali"); addOption(document.prodCatSubCatBrand_list.add_prodBrand,"18", "Tru Audio"); addOption(document.prodCatSubCatBrand_list.add_prodBrand,"19", "Von Schweikert"); } } if(document.prodCatSubCatBrand_list.add_prodCat.value == "5"){ if(document.prodCatSubCatBrand_list.add_prodSubCat.value == "0"){ document.prodCatSubCatBrand_list.add_prodBrand.disabled=false; addOption(document.prodCatSubCatBrand_list.add_prodBrand,"20", "Elan"); } } if(document.prodCatSubCatBrand_list.add_prodCat.value == "6"){ if(document.prodCatSubCatBrand_list.add_prodSubCat.value == "8"){ document.prodCatSubCatBrand_list.add_prodBrand.disabled=false; addOption(document.prodCatSubCatBrand_list.add_prodBrand,"21", "BDI"); addOption(document.prodCatSubCatBrand_list.add_prodBrand,"22", "Bello"); } if(document.prodCatSubCatBrand_list.add_prodSubCat.value == "7"){ document.prodCatSubCatBrand_list.add_prodBrand.disabled=true; addOption(document.prodCatSubCatBrand_list.add_prodBrand,"", "None"); } } if(document.prodCatSubCatBrand_list.add_prodCat.value == "7"){ if(document.prodCatSubCatBrand_list.add_prodSubCat.value == "10"){ document.prodCatSubCatBrand_list.add_prodBrand.disabled=false; addOption(document.prodCatSubCatBrand_list.add_prodBrand,"23", "Richard Gray's Power Company"); } if(document.prodCatSubCatBrand_list.add_prodSubCat.value == "9"){ document.prodCatSubCatBrand_list.add_prodBrand.disabled=true; addOption(document.prodCatSubCatBrand_list.add_prodBrand,"", "None"); } if(document.prodCatSubCatBrand_list.add_prodSubCat.value == "11"){ document.prodCatSubCatBrand_list.add_prodBrand.disabled=true; addOption(document.prodCatSubCatBrand_list.add_prodBrand,"", "None"); } if(document.prodCatSubCatBrand_list.add_prodSubCat.value == "12"){ document.prodCatSubCatBrand_list.add_prodBrand.disabled=false; addOption(document.prodCatSubCatBrand_list.add_prodBrand,"24", "Analysis Plus"); addOption(document.prodCatSubCatBrand_list.add_prodBrand,"25", "Tributaries"); } } } function removeAllOptions(selectbox) { var i; for(i=selectbox.options.length-1;i>=0;i--) { //selectbox.options.remove(i); selectbox.remove(i); } } function addOption(selectbox, value, text ) { var optn = document.createElement("OPTION"); optn.text = text; optn.value = value; selectbox.options.add(optn); } </script> please let me know if this is too confusing to follow (because it certainly looks like it could be), and i will attempt to clean it up hi Peers, i am having issue capturing the value of the selected DDL using IE. the code below works just fine in Firefox... // Create a new drop down list -- for text box use 'input' instead of 'select' var newDDL = document.createElement('select'); // size lenght of the DDL for both IE or Firefox newDDL.setAttribute("style","width:300px"); //firefox newDDL.setAttribute("width","300px"); newDDL.style.width = "300px"; newDDL.id = 'id' + elementid + ColumnElement; newDDL.setAttribute('name','newDDL'+ elementid+ColumnElement); // filling the DDL by ITEM array Elements var i=0; for (i=0;i<=rec_count;i++) { objOption = document.createElement('option') objOption.text = ITEM[i] newDDL.options.add(objOption) } counter++; newDDL.onchange = show1; both cases are giving the value selected in firefox function 1: function show1() { alert('id=' + this.getAttribute('id') + 'name = ' + this.getAttribute('name') + 'value=' + this.value ); } function 2: function show1() { alert('id=' + this.getAttribute('id') + 'name = ' + this.getAttribute('name') + 'value='+ this.getAttribute('value')); } any suggestion will be appreciated thanks Ok so i am trying to make 3 dropdowns based off a mysql table. and the 3 dropdowns need to be based off of the previous dropdown. i.e Source, School, Sub. Select Source, and the schools in dropdown 2 are based off of the source they selected, and when they select a school, all the sub cats for that school are in the sub category dropdown. It seems like a simple concept, but i've google'd EVERYWHERE and notihng. I have the 3 dropdown's pulling from my database perfectly. i just cannot base the next dropdown on the previous selection! I know nothing of javascript..im a front end designer with little php/mysql. I've read that Ajax is the way to go, so here i am ! any tutotials, links or sample script layouts i can use would be amazing! Thank you! jt Hi All, i know how to create a dynamic form or DIv ..but what i do not know is how to create a dynamic form/ or div into a previous dynamic one.. i need basically to see 5 dynamic forms / DIV in cascade where each one trigger the one coming after.. For what i need that : i have my user inserting information on the level 1. let say Copagny info 2- then he will be asked if he wants to add a sub level information ( subform) for that compagny or even many subforms at the same level .. and so on... 3- those sub level ( subforms ) can also call their respective subforms.. Any idea how to design this ? thanks So i have a form with fields (30+), and about 5 of them are fields that need to pass into my dropdown (actually a dynmaic dropdown, select SOURCE, then whatever source u select it'll show options that are mysql source=$source), so it can go into my mysql query, and filter out the best results. (i.e date_of_birth, min_credits, state, etc). Needs to be done without submitting, hence javascript. Im echo'ing my query and its saying the variables i'm trying to pass are UNDEFINED. Am I not passing the vars correctly? do i need to prep the vars to "grab" them in the current field? this is what i have in my <head> Code: <script language="javascript" type="text/javascript"> function getXMLHTTP() { //fuction to return the xml http object var xmlhttp=false; try{ xmlhttp=new XMLHttpRequest(); } catch(e) { try{ xmlhttp= new ActiveXObject("Microsoft.XMLHTTP"); } catch(e){ try{ xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e1){ xmlhttp=false; } } } return xmlhttp; } function getSchool(id,hs_grad_year,dob_day,dob_month,dob_year,min_credits,state) { var strURL="findSchool.php?source="+id+"&hs_grad_year="+hs_grad_year+"&dob_day="+dob_day+"&dob_month="+dob_month+"&dob_year="+dob_year+"&min_credits="+min_credits+"&state="+state; var req = getXMLHTTP(); if (req) { req.onreadystatechange = function() { if (req.readyState == 4) { // only if "OK" if (req.status == 200) { document.getElementById('schooldiv').innerHTML=req.responseText; } else { alert("There was a problem while using XMLHTTP:\n" + req.statusText); } } } req.open("GET", strURL, true); req.send(null); } } function getSub(id,cid) { var strURL="findSub.php?source="+id+"&cid="+cid; var req = getXMLHTTP(); if (req) { req.onreadystatechange = function() { if (req.readyState == 4) { // only if "OK" if (req.status == 200) { document.getElementById('subdiv').innerHTML=req.responseText; } else { alert("There was a problem while using XMLHTTP:\n" + req.statusText); } } } req.open("GET", strURL, true); req.send(null); } } </script> The only var that is passing is SOURCE, and that's because its the name of the first dropdown I'm VERY new to javascript, do i need to set up like a GET method on my RECEIVING page? or can i just pass variables through? Do i need to get the "existing" data in the fields first? Thanks in advance, JT I am developing a messaging service between members of my site. I am developing this with asp.net mvc. When a user goes to the SendMessage view to send a message to another member, there is a dropdown list which presents the sender with all the members of the site, which he or she will pick as the recipient. However, i don't want it to be a dropdown, i want it to be a text box, where a user types in the first couple of letters of a name, and the dropdown appears then with only the members which have the same couple of letters. This is basically like every email system out there (facebook and gmail have it just like that). And after they chose one, they can select another one in the same textbox, just separated by a comma or something like that. Basically, how do i achieve that in javascript? I'm not even sure what that functionality is called, that's why i had to explain it properly. Any help is greatly appreciated. thank you I have made a script where you can add extra fields, and next to the row is a span that automatically displays the outcome from a calculation of three fields in that row. i.e. Q x (B - A) = total. Here is the bit that does the calculation: Code: function advCalc(selected) { var result = Number(document.formmain.elements["quantity"+selected].value) * (Number(document.formmain.elements["provideamount"+selected].value) - Number(document.formmain.elements["supplyamount"+selected].value)) ; result = result.toFixed(2) ; result = addCommas(result) ; document.getElementById("total"+selected).innerHTML = result ; } The bit that adds a new row of fields is: Code: function addPart(divName){ var newdiv = document.createElement('div') ; newdiv.setAttribute('id', 'partrow' + counter) ; newdiv.setAttribute('style', 'clear:both;') ; newdiv.innerHTML = "<div style='float:left;width:40px;text-align:center;margin:5px 5px 0px 0px;'>\r<input onkeyup=\"advCalc('" + counter + "')\" id=' quantity " + counter + "' type='text' value='1' size='1'/>\r</div>\r<div style='float:left;width:100px;text-align:left;margin:5px 0px 0px 0px;'>\r<input id='manufacturer" + counter + "'type='text' value='' size='9'/>\r</div>\r<div style='float:left;width:95px;text-align:left;margin:5px 5px 0px 0px;'>\r<input id='partnumber" + counter + "'type='text' value='' size='9'/>\r</div>\r<div style='float:left;width:80px;text-align:left;margin:5px 5px 0px 0px;'>\r<input id='supplier" + counter + "'type='text' value='' size='4'/>\r</div>\r<div style='float:left;width:100px;text-align:left;margin:5px 5px 0px 0px;'>\r<input id='type" + counter + "'type='text' value='' size='6'/>\r</div>\r<div style='float:left;width:85px;text-align:left;margin:5px 5px 0px 0px;'>\r<input id='deliverytime" + counter + "'type='text' value='' size='13'/>\r</div>\r<div style='float:left;width:40px;text-align:left;margin:5px 0px 0px 45px;'>\r<select id='supplyCurrency" + counter + "'>\r<option value='pound' selected='selected'>£</option><option value='dol'>$</option><option value='euro'>€</option></select>\r</div>\r<div style='float:left;width:15px;text-align:left;margin:5px 5px 0px 0px;'>\r<input onkeyup=\"advCalc(\'" + counter + "\')\" id=' supplyamount " + counter + "'type='text' value='' size='3'/>\r</div>\r<div style='float:left;width:40px;text-align:left;margin:5px 0px 0px 45px;'>\r<select name='provideCurrency" + counter + "'><option value='pound' selected='selected'>£</option><option value='dol'>$</option><option value='euro'>€</option></select>\r</div>\r<div style='float:left;width:15px;text-align:left;margin:5px 5px 0px 0px;'>\r<input onkeyup=\"advCalc(\'" + counter + "\') id=' provideamount " + counter + "' type='text' value='' size='3'/>\r</div>\r<div style='float:left;width:20px;text-align:left;margin:5px 0px 0px 45px;'>\r<strong>£</strong>\r</div>\r<div style='float:left;width:40px;text-align:left;margin:5px 5px 0px 0px;'><span id=' total " + counter + "'></span></div> \r" ; document.getElementById(divName).appendChild(newdiv) ; counter++ ; } The problem I am having is that it works fine for the first row which is hardcoded as e.g. id="provideamount0" etc. It isn't working for any other fields added but I can't see what is wrong So I have a little calendar widget on my site, for people to choose their dates for a reservation system. They then click a 'Book Now' button which creates a dynamic url (using their start date and the number of dates) to the booking engine. The problem is, the way it accomplishes this (window.location.href=), breaks cross-domain tracking on Google Analytics. And I'm not smart enough to figure out how to do it any other way. What I'd like to do is have clicking the Book Now button change the URL in the form action within the form with ID resForm, and then submit the form. I'm hoping someone can help me edit the form so that it accomplishes this. I'd be incredibly thankful. This is what I currently have: Code: <script> jQuery(document).ready(function($) { $(".book-now").click(function() { if($('#check-in').length > 0 && $('#DepartureDate').val() != '') { var data = $('#check-in').val(); var arr = data.split('/'); var datac = $('#DepartureDate').val(); var arr2 = datac.split('/'); var oneDay = 24*60*60*1000; // hours*minutes*seconds*milliseconds var firstDate = new Date(arr[2],arr[0] -1,arr[1]); var secondDate = new Date(arr2[2],arr2[0] -1,arr2[1]); var diffDays = Math.round((firstDate.getTime() - secondDate.getTime())/(oneDay)); if ((diffDays) < 0) { diffDays = Math.abs(diffDays); var link = "https://res.windsurfercrs.com/bbe/page1.aspx?propertyID=13841&checkin=" + arr[0] + "/" + arr[1] + "/" + arr[2] + "&nights=" + diffDays; console.log(link); window.location.href= link; } else { alert ('Please fill in correct Check-In and Check-Out dates. The Check-In date must be before the Check-Out date.'); } } else { alert ('Please fill in a Check-In and Check-Out date, thanks!'); } }); }); </script> The form looks like this: Code: <form action="#" onSubmit="_gaq.push(['_linkByPost',this]);" method="post" id="resForm"> <input type='text' name="checkin" id="check-in" readonly="readonly" style="cursor: text" data-default="MM/DD/YYYY" class='arrivaldate'/> <input name="checkout" id="DepartureDate" readonly="readonly" style="cursor: text" data-default="MM/DD/YYYY" class='departuredate'/> <input type="button" value="BOOK NOW" class='book-now' /> </form> Reply With Quote 01-25-2015, 12:46 AM #2 Old Pedant View Profile View Forum Posts Supreme Master coder! Join Date Feb 2009 Posts 28,310 Thanks 82 Thanked 4,754 Times in 4,716 Posts Just call the _gaq() function manually. Code: _gaq.push(['_linkByPost',document.getElementBy("resForm")]) window.location.href= link; What I mean by this is how do you load an xml document that has been inputted as a string in a form. I would've assumed it was something like this, but this doesn't seem to be working. Code: <html> <head> <script type="text/javascript"> function loadXML(file) { var moz = (typeof document.implementation.createDocument != 'undefined'); var ie = (typeof window.ActiveXObject != 'undefined'); var xmlDoc; if (moz) xmlDoc = document.implementation.createDocument("", "", null); else if (ie) xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); xmlDoc.async = false; xmlDoc.load(file); return xmlDoc; } </script> </head> <body> <input type="text" name="input1" size="15"/> <input type="button" value="LOADXML" loadXML(input1.value)"/> </body> </html> Where 'input1' would be an xml file in the same folder. I have added a booking form to a website with belongs to fastbooking. You can see a temporary website here. http://www.kohkoodguide.com/ It works perfectly fine in Mozilla Firefox, Google Chrome, Opera and Safari but it does not load on Internet Explorer. On the other browsers the form loads todays date and the year is generated but on IE the date stays on 01-01 and no year is generated. I'm using wordpress as a cms. I think the code that is not loading is Code: <body onLoad='start();'> But I'm not sure. The code of the year is Code: <select name='fromyear' class="input" onChange='update_departure();'> <option value="0"></option> </select> But since it's no just the year I assume its the onload code. I tried to add the onload to the header function like this Code: <body onLoad='start();' <?php if(function_exists('body_class')) body_class(); ?>> So now wordpress generates the following code when it loads the page Code: <body onLoad='start();' class="home page page-id-6 page-template page-template-default logged-in"> But sadly the date still does no load on Internet Explorer. I'm out of ideas, anyone? |