jayapalchandran
05-06-2009, 03:46 PM
Hi,
i have a form with its action set to something.php . and i have a hidden button with name action. so within this form there are two properties with the same name
like fom.action = 'a.php' and <input type='hidden' name='action' value='login'>
like the following
CODE ONE
<form name='aform' action='a.php' method='post' >
<input type='hidden' name='action' value='login'>
<input type='text' name='email'>
<input type='button' value='Send' onclick='validate()'>
</form>
and the script is as follows
<script>
function oh()
{
if(true) // if validatio is true then the form should submit
document.aform.submit()
}
</script>
the above dosen't work because the form.action is getting overridden by hidden type action. this is my assumption.
where as look at the following
CODE TWO
<form name='aform' action='a.php' method='post' onsubmit='return oh()' >
<input type='hidden' name='action' value='login'>
<input type='text' name='email'>
<input type='submit' value='Send' onclick='validate()'>
</form>
and the script is as follows
<script>
function oh()
{
if(true) // if validatio is true then the form should submit
return true
else return false
}
</script>
the above set of code (CODE TWO) works even though there are two properties with the name action... where as the (CODE ONE) will not submit properly...
can any one tell me why? anyway the form is working...
and please dont tell the better give a different name to the input field because some frameworks of php expects an action key value pair ...
so when document.fomname.submit() is called then the form doesn't submit properly where as if we let the default handlers to submit then it works... why this differente
anyway i use my own style of submitting the forms but i want to know the difference ...
...
i have a form with its action set to something.php . and i have a hidden button with name action. so within this form there are two properties with the same name
like fom.action = 'a.php' and <input type='hidden' name='action' value='login'>
like the following
CODE ONE
<form name='aform' action='a.php' method='post' >
<input type='hidden' name='action' value='login'>
<input type='text' name='email'>
<input type='button' value='Send' onclick='validate()'>
</form>
and the script is as follows
<script>
function oh()
{
if(true) // if validatio is true then the form should submit
document.aform.submit()
}
</script>
the above dosen't work because the form.action is getting overridden by hidden type action. this is my assumption.
where as look at the following
CODE TWO
<form name='aform' action='a.php' method='post' onsubmit='return oh()' >
<input type='hidden' name='action' value='login'>
<input type='text' name='email'>
<input type='submit' value='Send' onclick='validate()'>
</form>
and the script is as follows
<script>
function oh()
{
if(true) // if validatio is true then the form should submit
return true
else return false
}
</script>
the above set of code (CODE TWO) works even though there are two properties with the name action... where as the (CODE ONE) will not submit properly...
can any one tell me why? anyway the form is working...
and please dont tell the better give a different name to the input field because some frameworks of php expects an action key value pair ...
so when document.fomname.submit() is called then the form doesn't submit properly where as if we let the default handlers to submit then it works... why this differente
anyway i use my own style of submitting the forms but i want to know the difference ...
...