October 22, 2024
Chicago 12, Melborne City, USA
PHP

How do I pass a hidden text field as well as changle the form action


I have a script that will take a page name and change the form action, which will then take me to that page. However, I also want the ID for the page content to be passed to it. I assumed that a hidden field would work. I get the page, but there is no content.

<script language="javascript">
<!-- Script courtesy of http://www.web-source.net - Your Guide to Professional Web Site Design and Development
function goto(form) { var index=form.select.selectedIndex
if (form.select.options[index].value != "0") {
location=form.select.options[index].value;}}
//-->
</script>
<form name="form1">
<input type="hidden" name="id" id="id" value="<?php echo $row['id'];?>">
<select name="select" onchange="goto(this.form)">
<option value="">-------Choose a Selection-------
<option value="view.php">View
<option value="download.php">Download
</select>
</form>

I then capture the ID on the receiving page with.

if ($_SERVER["REQUEST_METHOD"] == "POST") {
    // collect value of input field
    $app_id = $_POST['id'];
}



You need to sign in to view this answers

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video