Link to home
Start Free TrialLog in
Avatar of fastfind1
fastfind1

asked on

PHP submit form and update variable onclick

Trying to create a form where the user searches for a name.  The first step is to select whether they want to search for a common name or a scientific name.  The next step is to select the first letter of that name (A, B, C, etc.).  When they click on the letter (i.e. A), I need the hyperlink to update a hidden field with the letter they clicked on and then pass the form (which passes the choice of common name or scientific name and the letter) to the next page.

My code below does not update the letter they chose.  Please advise
<form id="form1" name="form1" method="post" action="grass1.php">
  <p>&nbsp;  </p>
  <table width="889">
    <tr>
      <td width="140"><label>
        <input name="name" type="radio" id="name_0" value="0" checked="checked" />
        Common Name</label></td>
      <td width="6">&nbsp;</td>
      <td width="727">Click the letter below</td>
    </tr>
    <tr>
      <td><label>
        <input type="radio" name="name" value="1" id="name_1" />
        Scientific Name
        <input name="hide" type="hidden" id="hide" value="<?php echo $letter; ?>" />
      </label></td>
      <td>&nbsp;</td>
      
      <td><a href=""<?php $letter = 'A';?> onclick="document.form1.submit();return false">A
        
      </a><a href=""<?php $letter = 'B';?> onclick="document.form1.submit();return false">B
        
      </a></td>
    </tr>
  </table>
  
</form>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of joep1978
joep1978

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial