I'm trying to post some data when visitors click on a "td".
Here is the code:
<form method="post" name="randoms">
<tr><td value="1" name="somedata">Click me 1</td></tr>
<tr><td value="2" name="somedata">Click me 1</td></tr>
<tr><td value="3" name="somedata">Click me 1</td></tr>
<tr><td value="4" name="somedata">Click me 1</td></tr>
</form>
What I want here is that if a visitor clicks at "Click me 1" it post the form and then I'll be able to grab the somedata with PHP.
<?php
$somedata = $_POST["somedata"];
?>
I've tried to solve this, but I cannot find a way to do this, I'm pretty sure there are lots of way to do it.
I've tried this JavaScript:
<script type="text/javascript">
function submitForm(sub) {
document.forms[sub].submit();
}
</script>
and then I've tried to use:
<a HREF="#" onClick="submitForm('randoms')"> Somedata1 </a>