I am designing simple HTML with a drop-down list and a button.
I want to know how to retrieve the selected drop-down item into php variable. I am writing php-html embed code. I am confused about how to get the particular value in php variable. Also, I would like to know how to download a file after selecting that particular item. I already created downloading file, but I have no idea how to invoke those from selected drop-down item.
Any help will be appreciated.
Thank you.
I am pasting some php-html code which I am trying:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Get All Reports</title>
</head>
<body>
<center>
<div>
<form action="">
<table>
<tr><td>
<select onchange="ReportList(this.form,0)">
<option value="SubscriptionReport.php" >Subscription Report
<option value="DownloadHistoryReport.php">DownloadHistory Report
<option value="AppEventReport.php">AppEvent Report
</select>
</td></tr>
<tr><td>
<button name="isSubmit">Download</button>
</td></tr>
</table>
</form>
</div>
</center>
</body>
</html>
The value of that input will be passed via whatever method you use in your form. The page it is sent to will access the form input value through
$_GETor$_POST, whichever method was used.Would be accessed, in process.php, as such:
Notice that the input is passed via its
nameand not itsidattribute.For a GET form submission:
Would be accessed, in process.php, as such:
Note that when you submit a form via GET, it appends the key/value pair to the querystring:
If you want to submit your form to the same page on which it exists, just leave the
actionattribute blank.NOTE: PHP can only access form variables once they have been submitted. If you want to retrieve the value of a form element, you must use javascript event handlers. PHP is server-side and cannot react to user input until the server receives it. Javascript is client-side. It “sees” what the user does in the browser and can handle those events.