Page 1 of 1

Unexpected Characters in Action/Value tag

Posted: Tue Feb 08, 2005 11:21 pm
by MuzzledKestrel
I'm trying to create two dynamically loaded select boxes, one for a database, and the other for its respective tables. Depending on which table is selected, I will list all the records in that particular table. Ideally, when I change the selectedIndex on one of the select boxes it should reload the page and display a new set of records for the new table.

I'm storing the selectedIndex of each select box in hidden fields.

The problem I'm having is that values of the hidden fields in the URL when the new page is loaded are surrounded by plus signs for whatever reason....Can anyone explain what is going on? Please try running the code below to see what I mean. Thanks.

Sample.php
------------------

Code: Select all

<script>
   function init()
   &#123;
      var dIndex = document.getElementById("databaseNum").value;
      document.getElementById("dbSelect").selectedIndex = dIndex;  

      var tIndex = document.getElementById("tableNum").value;
	document.getElementById("tableSelect").selectedIndex = tIndex;
   &#125;   
 
   function chooseDatabase(index)
   &#123;
      document.getElementById("databaseNum").value = index; 
	document.forms&#1111;0].submit();
   &#125;

   function chooseTable(index)
   &#123;
      document.getElementById("tableNum").value = index; 
	document.forms&#1111;0].submit();
   &#125;
</script>

<html>
<body onload="init()">
<form id="form1">
    <table cellspacing="2" cellpadding="2" border=1>
       <tr>
	    <td align="center">
 		 <fieldset>
		 <legend>Available Databases</legend>
             <select onChange="chooseDatabase(this.selectedIndex);" id="dbSelect">
		       <option> database 1 </option>
			 <option> datebase 2 </option>
			 <option> database 3 </option>
			 <option> database 4 </option>
    		 </select>
	       </fieldset>
             <input type="text" name="databaseNum" value=" <?php echo($databaseNum); ?> "/>
		 
		 <fieldset>
		 <legend> Available Tables </legend>
		 <select onChange="chooseTable(this.selectedIndex);" id="tableSelect">	
		     <option> table 1 </option>
		     <option> table 2 </option>
		     <option> table 3 </option>
		     <option> table 4 </option>
		 </select>
		 </fieldset>
             <input type="text" name="tableNum" value="<?php echo($tableNum); ?> "/>
	    </td>	
	 </tr>
    </table>
</form>

</body>
</html>

feyd | :roll:

Posted: Tue Feb 08, 2005 11:23 pm
by feyd
the pluses are from the spaces you have around each value.

Posted: Wed Feb 09, 2005 6:23 am
by MuzzledKestrel
Whoa! That's wild! Thanks for answering my question.