Canadian

  


 
     






Return to previous page











 

Using Onchange to Submit a form without a Submit Button


     Additions to enable onchange in drop Menu:
        <script type="text/JavaScript">
       
<select name="selectcategory" class="style4" id="selectcategory" onchange="this.form.submit()">
            
<option value="" selected> Pick a Category</option>

     You need the option value to either be blank or have a message, otherwise the first item in your menu would
     never be available to be chosen because the function requires a change to work.

Submit Form using on Change

    
     This is an example of using onchange to submit the form, in this case, back to the same web page, itself.
     The is usefull where multiple forms are used, each depending on the choices from the last.

     Picking options when Menu is static:
     <form id="Selectcat" name="Selectcat" method="post" action="universaljoints.php">
        <span class="style1">Select a Category</span> <br />
        <select name="selectgroup" class="style3" id="selectgroup" onchange="this.form.submit()">
          <?php if ($cat != "-1")?>
             <option value="<?php echo $cat;?>"><?php echo $cat?></option>
          <?php else?>
             <option value="Select Category" selected>Select Category</option>
             <option value="Universal Joint">Universal Joint</option>
             <option value="Center Bearing">Center Bearing</option>
          <?php endif?>
        </select>
      </form></td>