user3277403
user3277403

Reputation: 137

PHP $_POST request not working

I have a drop down list in a html document, the options in the drop down are obtained via a PHP GET request, with Ajax populating the HTML document (Done on page load). The purpose of the drop down is to select an option, click the button, where the map will zoom to the extent. However the POST request for the selected option doesn't return anything.

Is there any reason for this?

HTML

<form id="form" method="post" action="php/zoom.php">
      <select id="selectProp" name="selectProp">
          <optgroup class="zoomProp_OG" id ="zoom">
          </optgroup>
      </select>
      <input type="button" value="Zoom to property" onClick="zoomToProp()">
 </form>

PHP

$attribute = $_POST['selectProp'];

Upvotes: 0

Views: 352

Answers (1)

Quentin
Quentin

Reputation: 943108

<input type="button"> is for a button that doesn't do anything (unless you hang JavaScript off it). Your form isn't being submitted so there is no POST request and the PHP doesn't run..

You need <input type="submit"> (or Ajax).

Upvotes: 2

Related Questions