passing value from one html to another

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • zedetach
    New Member
    • Sep 2008
    • 1

    passing value from one html to another

    I have inserted a function to help me pass a value from one html page to a drop down box in another html page. The problem is the code is working only in IE and not in Firefox.

    The code in the first page :-

    Code:
    <a href="reservation.html?rooms=0">Book Now</a>
    The code in the 2nd page :-

    Code:
      <script type="text/javascript">
    function parseState()
    		{
     		 	var q = unescape(location.search);
     			 q = q.substring(7, q.length);
      		if (q != "")
     		 {
        		document.getElementById('rooms').options.selectedIndex = q;
     		 }
    		}
    	</script>
    Last edited by acoder; Sep 26 '08, 11:15 AM. Reason: Added [code] tags
  • Rsmastermind
    New Member
    • Sep 2008
    • 93

    #2
    Hi friend in firefox the query string is not getting parsed correctly.

    The code you have written is a bit dependant becoz here you know about url exactly that after 7 characters there is your query but here is the most independant and efficient way of doing the same
    Code:
    q=location.search.substring(1);
    alert(q);//will give you every thing after the query parameter which you can split further for multiple parsing

    Comment

    Working...