I am trying to not have a submit button, is there any way that the form can submit when the user selects a value?
<form method="post" action="<?php echo $_SERVER['PHP_SELF']  ?>" >
    <table class="form">
            <select name="category" class="formfield" id="category">
                <option value="-1"> Category </option>
                <?php
                    $sql_contry = "SELECT * FROM category";
                    $rs_c = mysql_query($sql_contry);
                    while ($row_c = mysql_fetch_array($rs_c)) {
                        echo '<option value="'.$row_c['category'].'">'.$row_c['category'].'</option>';  
                    }
                ?>
             </select>
    </table>
</form>
                Here an example
<form>
    <select name='myfield' onchange='this.form.submit()'>
      <option selected>Milk</option>
      <option>Coffee</option>
      <option>Tea</option>
    </select>
    <noscript><input type="submit" value="Submit"></noscript>
</form>
Using noscript tag it allows browsers that are not JavaScript-enabled to still function.
Yes - use javascript:
Html:
<form id="frm">
   <select onchange="onSelectChange();">
          <option>1</option>
           <option>1</option>
   <select>
</form>
js:
function onSelectChange(){
 document.getElementById('frm').submit();
}
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With