Forum Moderators: open

Message Too Old, No Replies

Submitting form w/Firefox problem

         

dc_2000

4:18 am on May 26, 2006 (gmt 0)

10+ Year Member



Hi everyone:

Could someone suggest what am I doing wrong. I need this small code to submit form data when user clicks the link. It works OK in IE but submits empty string from Firefox.

Here's HTML & JavaScript:

<html>
<body>
<form method="POST" action="http://www.mysite.com/test_form.php" id="form1">
<p><input type="text" name="T1" size="20">
<a href="http://www.mysite.com/test_form.php" onclick="return linkClicked(this);">submit</a></p>
</form>

<SCRIPT LANGUAGE=javascript>
<!--
function linkClicked(obj)
{
//If Submit link is clicked
document.all.form1.submit();
return event.returnValue = false;
}
-->
</SCRIPT>
</body>
</html>

zangs

10:40 am on May 26, 2006 (gmt 0)

10+ Year Member



Hello

<SCRIPT LANGUAGE=javascript>
<!--
function linkClicked(obj)
{
//If Submit link is clicked
document.all.form1.submit();
return event.returnValue = false;
}
-->
</SCRIPT>

document.all can not work in FF, use document.getElementById or document.getElementsByName instead of you used.

Zangs

dc_2000

12:55 am on May 29, 2006 (gmt 0)

10+ Year Member



Thanks it helped, but there's one more problem. Do you know how to prevent default event from firing, something like IE's:

event.returnValue = false;

Somehow if I do not disable default execution of "onclick" from HREF tag, it simply follows the link without submitting form data.

texmex

11:22 pm on May 30, 2006 (gmt 0)

10+ Year Member



replace the last line of your function "return event.returnValue = false;"
with "return false;" as the last line of your function. (but without the inverted commas).