Submit

M

mtek

Hi,

Another issue. I'm triny to submit a form and have it run some
Javascript validation code before continuing. The button is an HTML
button. This is my code:

a href="javascript:document.Add_Data.action =
'savedata.php';document.Add_Data.submit();">SAVE Data</a>

The name of the form is Add_Data.

Any idea why that would not work??
 
T

Thomas 'PointedEars' Lahn

Another issue. I'm triny to submit a form and have it run some
Javascript validation code before continuing. The button is an HTML
button.

It is not. It is a pseudo-link.
This is my code:

a href="javascript:document.Add_Data.action =
'savedata.php';document.Add_Data.submit();">SAVE Data</a>

Yuck. Consider this instead:

<script type="text/javascript">
function submitMe(f)
{
f.action = "saveData.php";
f.submit();
}

document.write('<a href=""'
+ ' onclick="submitMe(document.forms[\'Add_Data\']);"'
+ '>SAVE Data<\/a>');
</script>

It would be better to use the same server-side script for all actions, a
real HTML button --

<input type="submit" name="save" value="SAVE Data">

-- for this one, and then use "isset ($_REQUEST['save'])" (or its quivalent)
server-side. This way it also worked if client-side script support was
unavailable.
The name of the form is Add_Data.

Any idea why that would not work??

a) Unsupported proprietary `javascript:' URI scheme
b) A form control named "submit" overriding the form's submit() method

RTFFAQ: http://jibbering.com/faq/


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,163
Latest member
Sasha15427
Top