So i have a simple form with a script to check the data before it submits:
<form action='self.php' name='my_form' method='post' onSubmit="return checkit();">
<select name='menu' id='menu'>
<option value='00'>ZERO</option>
<option value='01'>ONE</option>
</select>
</form>
I want to have a pop up or alert box to request more information. Kinda like:
<script type="text/javascript">
function checkit()
{
if(document.my_form.menu.value == "01")
{
var getColor = prompt("Enter Color: ", "enter the color");
return false;
}
</script>
How would I then pass the variable “getColor” to a PHP variable on submit?
Almost something like:
<?php
$theColorIs = getColor;
?>
Is there a way to do this? I know that PHP is server side and the script isn’t, but the form has not been submitted because the script halts it. It seems like a simple thing to do, is there another option?
Thanks early for the help!!!
You can use hidden fields in your form to store the value and retrieve it through PHP
the html form:
the script:
So when the form is submitted, the value is stored in $_POST[‘myhiddenfield’]