| | |
Dynamic select boxes not setting values on page load in safari
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Mar 2008
Posts: 78
Reputation:
Solved Threads: 1
Hey everyone,
The problem I'm having is regarding trying to persist a users search selection.
For example a user searches (for holidays) on the homepage. I would like the search box which is displayed on every page to hold the values of the previous search which are persisted in a session array.
I'm using the script from http://www.javascripttoolbox.com/lib/dynamicoptionlist/ to help me do the dependent select boxes and everything is working apart from when I try and use it to set the values of the search box at the bottom of the page if there has been a previous search.
Here's a snippet of code to help get across what I mean.
This works in IE and FF but not in Safari and Chrome or I assume any webkit based browser.
Can anyone offer any help on this. I've tried researching and playing about with various things but nothing works.
I can say this if I alert() out the departure year after it's been set it does come up as 2010 (or whatever) but then after the page loads it is still set as 'year'
Thanks for any help in advance,
Richard
The problem I'm having is regarding trying to persist a users search selection.
For example a user searches (for holidays) on the homepage. I would like the search box which is displayed on every page to hold the values of the previous search which are persisted in a session array.
I'm using the script from http://www.javascripttoolbox.com/lib/dynamicoptionlist/ to help me do the dependent select boxes and everything is working apart from when I try and use it to set the values of the search box at the bottom of the page if there has been a previous search.
Here's a snippet of code to help get across what I mean.
php Syntax (Toggle Plain Text)
<?php if( isset($_SESSION['previousUserSearch']['dynamic']) && !isset($_GET['load']) ){ echo '<script>' . "\n"; //Below deals with persisting the year>month>day echo 'document.getElementById("departure_year").value = "'.$_SESSION['previousUserSearch']['dynamic']['departureyear'].'";' . "\n"; echo 'yearMonthDay.forField("departuremonth").setValues("'.$_SESSION['previousUserSearch']['dynamic']['departuremonth'].'");' . "\n"; echo 'yearMonthDay.forField("departureday").setValues("'.$_SESSION['previousUserSearch']['dynamic']['departureday'].'");' . "\n"; echo 'alert(document.getElementById("departure_year").value);'; //Deals with persisting the Country Resort echo 'document.getElementById("to").value = "'.$_SESSION['previousUserSearch']['dynamic']['country'].'";' . "\n"; echo 'countryResort.forField("resorts").setValues("'.$_SESSION['previousUserSearch']['dynamic']['resorts'].'");' . "\n"; //deals with persisting the rooms required echo 'document.getElementById("rooms").value = "'.$_SESSION['previousUserSearch']['dynamic']['rooms'].'";' . "\n"; //deals wiith persisting the duration echo 'document.getElementById("duration").value = "'.$_SESSION['previousUserSearch']['dynamic']['duration'].'";' . "\n"; //deals with persisting the party info echo 'document.getElementById("adults").value = "'.$_SESSION['previousUserSearch']['dynamic']['adults'].'";' . "\n"; echo 'document.getElementById("children").value = "'.$_SESSION['previousUserSearch']['dynamic']['children'].'";' . "\n"; echo 'addChildrenAgesDynamic();'; if( $_SESSION['previousUserSearch']['dynamic']['children'] != 0 ){ $i = 1; while( $i <= $_SESSION['previousUserSearch']['dynamic']['children'] ){ echo 'document.getElementById("childAge_'.$i.'").value = "'.$_SESSION['previousUserSearch']['dynamic']['childAge_'.$i.''].'";' . "\n"; $i++; } } echo 'document.getElementById("infants").value = "'.$_SESSION['previousUserSearch']['dynamic']['infants'].'";' . "\n"; //deals with persisting the accommodation options echo 'document.getElementById("board_basis").value = "'.$_SESSION['previousUserSearch']['dynamic']['board_basis'].'";' . "\n"; echo 'document.getElementById("hotel_rating").value = "'.$_SESSION['previousUserSearch']['dynamic']['hotel_rating'].'";' . "\n"; echo '</script>' . "\n"; }
This works in IE and FF but not in Safari and Chrome or I assume any webkit based browser.
Can anyone offer any help on this. I've tried researching and playing about with various things but nothing works.
I can say this if I alert() out the departure year after it's been set it does come up as 2010 (or whatever) but then after the page loads it is still set as 'year'
Thanks for any help in advance,
Richard
![]() |
Similar Threads
- Setting Values of Input Box in Iframes via Javascript (JavaScript / DHTML / AJAX)
- Dynamic Combo boxes JS or AJAX ?? (PHP)
- Display same mysql results in several select boxes (PHP)
- Nested Select Boxes in Javascript (JavaScript / DHTML / AJAX)
- Dynamic Select Boxes (JavaScript / DHTML / AJAX)
- Smart chained select boxes (JavaScript / DHTML / AJAX)
- Setting a static page file (virtual memory) (Windows tips 'n' tweaks)
- Hotmail "page cannot load" (Web Browsers)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: [ask] JQuery preventDefault is not working
- Next Thread: How can i build a hyperlink to bypass this js form
| Thread Tools | Search this Thread |
.net 2.0 adobe adobeacrobat ajax ajaxcode ajaxexample ajaxhelp asp asp.net automatically box bug bugs cakephp cart cfquery check class click close code codebox codes combo count debugger decimal development distinct dom download editor epilepsy events exists explorer ext external firefox flash focus form frameworks getselection glitch google griefers gwt hackers hiddenvalue highlightedword html htmlform iframe images input internet java javascript jquery jsf jsfile jsp listbox logfiles masterpage mp4 mysql news paypal pdf php post preview problem programming regex resultset runtime safari save scale scriptlets scroll security select shopping size software tables textbox treeview unicode validation vulnerability window windowsxp wysiwyg zeroday






