I call some links (opening table in the div) in the form
<A HREF="#1" onClick = ?????>button 1<A>
<A HREF="#2" onClick = ?????>button 2<A>
<A HREF="#3" onClick = ?????>button 3<A>
I would like through the onClick function to send data (numbers: 1, 2, 3) and receive it in PHP in the same document. I guess I have to commit to this form.
How to do it?
EDIT ————————————-
I try the @gilly3 way
<script language="JavaScript">
function submitValue (n) {
var f = document.forms.myform_1;
f.myNumber.value = n;
f.submit();
}
</script>
<?php
global $PHP_SELF;
echo "<form action='". htmlentities($PHP_SELF)."' method=\"POST\" id=\"myform_1\">";
?>
<input type="hidden" name="myNumber" />
<a href="#1" onclick="submitValue(1)">button 1</a>
<a href="#2" onclick="submitValue(2)">button 2</a>
<a href="#3" onclick="submitValue(3)">button 3</a>
</form>
tested – working ok. thnks for your help
Add hidden fields to your form. In your click handler, write whatever value you want to the hidden fields and call
form.submit().Use it like this:
Or get the value from
$_GETand skip the JavaScript: