How do I disable Submit until Select choice has been made

New to this but have made my way through many things but now I am stumped: I have a php page that does numerous things with a couple different form area’s. In one form area I pull a list of records from a database and display them in a select window. After the selection has been made by clicking on it, I want the NEXT button to be Enabled and not before. I have tried so many things I am back at square 1


<form name= "Next_Button_Form" method="post" action="EditRecordPage.php">
Choose The Correct Item and Click :&nbsp; 
	<input type="submit" id="nextbutton" name="nextbutton" value="NEXT"  ></strong>


<select class="select" name="selected_item" size="9" id="selected_item" onChange="document.select_item_form.edit_item.value='false'; submit();" style="width: 290px">
		GetItems($item_id, $cost, $qtyonhand, 20);

The button and the Select work fine, but I want the Button Disabled UNTIL something is selected with the OnChange


The “normal” logic would just be to make the select required. The submit wont work until something is selected.

<!DOCTYPE html>

<select required>
  <option value="">None</option>
  <option value="volvo">Volvo</option>
  <option value="saab">Saab</option>
  <option value="mercedes">Mercedes</option>
  <option value="audi">Audi</option>
<input type="submit">


Simple enough if it is in the same form space but the select is in one form space and the submit is in another due to the need to do other things before and after in the form - I think I got it covered with //<input type="submit" id="nextbutton" value="NEXT" <?php if ($enablenextbutton == ''){ ?> disabled <?php } ?> > and setting //$enabalenextbutton="Yes" while the select sequence runs.

Only issue now is it only works once and disables my SELECT from selecting a different item which wasn’t the case before adding the php if

No idea what you are talking about.

If you want help you are going to have to explain exactly what you are doing rather than asking about your attempted solution to doing it.

Grrr - it took my Code sample out when I replied - lets try this again - This works to enable the Next after SELECT is done and //$enablenextbutton="Yes" is set during SELECT process
//<input type="submit" id="nextbutton" value="NEXT" <?php if ($enablenextbutton == ''){ ?> disabled <?php } ?> >

The issue is that the SELECT won’t allow me to CHANGE the Selected item now but before just adding the php in my submit it did

I fixed it, thanks for the input though

To do what I was trying to do which is enable and disable a button in a different form on the same page after SELECTING and item from a MYSQL query select list you do this:

//<input type="submit" id="nextbutton" value="NEXT" <?php if ($enablenextbutton == ''){ ?> disabled <?php } ?> >

It he SELECT FUNCTION $enablenextbutton = “Yes”;

SO if you use one action to get the list and then another action to SELECT FROM IT - the NEXT will not be enabled until you have SELECTED something

That sounds like a JavaScript problem. JavaScript deals more with user interface on the page. PHP is really more for data processing and heavy backend stuff.

Also, when formatting code on this forum, you can either click on the </> icon above in the editor and place your codes inside what the editor gives.

Thanks spaceshiptrooper - I finally figured out the format for posting.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.