fh03
June 6th, 2004, 05:16 AM
alright I'm writing form which calls out a function F1 onsubmit
but I want it to do that based on what the user answers to the last question on the form
this question has a yes/no answer, if the answer is yes, I want it to call F1 as it would and the function basically sends the form contents to two different places, if the answer was no, I want it to just submit it to one place...
now here's how I've implemented this...
FORM method="POST" action="form.php" onsubmit="submitit(this)">
echo "<input name='smoke' type='radio' value='No' onClick='smoker('NO')'>";
echo "No";
echo "<input type='radio' name='smoke' value='Yes' onClick='smoker('YES')'>";
echo "Yes";
function smoker($sm1)
{
$smoke = $sm1;
if ($smoke == 'YES')
{
echo "<script type='text/javascript'>";
echo "function submitit(fh)";
//below line would submit to two places
echo "{ fh.submit(); fh.target='_blank' fh.action='form2.php';";
echo "fh.submit(); return false; }</script>";
}
else //just submit to one place
{
echo "<script type='text/javascript'> function submitit(fh) { fh.submit(); return false; }</script>";
}
}
echo "<INPUT type='submit' value='Click me!'>";
but this does not do what I want it to do... it just always submits to the 1st form... and nothing else, I've been tweeking around for quite a while, was wondering if anyone can tell me what I'm doing wrong, or perhaps provide a better solution to my problem?
thank you
but I want it to do that based on what the user answers to the last question on the form
this question has a yes/no answer, if the answer is yes, I want it to call F1 as it would and the function basically sends the form contents to two different places, if the answer was no, I want it to just submit it to one place...
now here's how I've implemented this...
FORM method="POST" action="form.php" onsubmit="submitit(this)">
echo "<input name='smoke' type='radio' value='No' onClick='smoker('NO')'>";
echo "No";
echo "<input type='radio' name='smoke' value='Yes' onClick='smoker('YES')'>";
echo "Yes";
function smoker($sm1)
{
$smoke = $sm1;
if ($smoke == 'YES')
{
echo "<script type='text/javascript'>";
echo "function submitit(fh)";
//below line would submit to two places
echo "{ fh.submit(); fh.target='_blank' fh.action='form2.php';";
echo "fh.submit(); return false; }</script>";
}
else //just submit to one place
{
echo "<script type='text/javascript'> function submitit(fh) { fh.submit(); return false; }</script>";
}
}
echo "<INPUT type='submit' value='Click me!'>";
but this does not do what I want it to do... it just always submits to the 1st form... and nothing else, I've been tweeking around for quite a while, was wondering if anyone can tell me what I'm doing wrong, or perhaps provide a better solution to my problem?
thank you