Skip to content

Instantly share code, notes, and snippets.

@klang
Created January 10, 2012 12:22
Show Gist options
  • Save klang/1588773 to your computer and use it in GitHub Desktop.
Save klang/1588773 to your computer and use it in GitHub Desktop.
html array send to php action
<html>
<header>
<script type="text/javascript">
function btnClick(aBtn) {
with (aBtn.form) {
event.value = aBtn.name;
submit();
}
}
</script>
</header>
<body>
<form name="choiceForm" method="post" action="foo.php">
<input type=hidden name="module" value="this_one">
<input type=hidden name="event" value="">
<input type=text name="entries[]" value="val1"><br>
<input type=text name="entries[]" value="val2"><br>
<input type=text name="entries[]" value="val3"><br>
<input type=text name="entries[]" value="val4"><br>
<input type=text name="entries[]" value="val5"><br>
<input type=text name="entries[]" value="val6"><br>
<button type="button" name="save_entries" onClick="btnClick(this)">Save entries</button>
<input type="submit" name="Submit" value="Submit">
</form>
</body>
</html>
<?php
print"<pre>module:\n".print_r($module, true)."</pre>";
print"<pre>event:\n".print_r($event, true)."</pre>";
print"<pre>entries:\n".print_r($entries, true)."</pre>";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment