Welcome to WebmasterWorld Guest from

Forum Moderators: incrediBILL

Message Too Old, No Replies

Problem across browsers in submitting form through Javascript



12:27 pm on May 21, 2007 (gmt 0)

5+ Year Member

I am submitting a form using javascript code document.formname.submit()

It works fine in IE but the other browsers are not supporting this feature. I have tried Firefox, Netscape and Opera. The Javascript Error Console in Firefox and Netscape showed error on that very line.

Have anyone got any idea. I searched google but thats a real waste of time.....


4:47 pm on May 21, 2007 (gmt 0)

WebmasterWorld Senior Member tedster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

First, I'd say validate your html against the doctype you are using to find any missing close tags or other true errors. Also try document.forms.formname.submit() - that might make a difference.


8:40 am on May 22, 2007 (gmt 0)

5+ Year Member


No result. I have also tried document.getElementById('f1').submit() where f1 is the id of the form.

Can anyone help me out?


1:56 pm on May 22, 2007 (gmt 0)

5+ Year Member

What about :


5:36 am on May 23, 2007 (gmt 0)

5+ Year Member

It works. But my purpose has not solved yet. I want to store some values in hidden fields in a form and submit it automatically when I call the form submitting function. My code is:
<form name="f1" action="search_cdr_result.php" method="post">
<input type="hidden" name="sDate" value="<?php echo($sDate);?>">
<input type="hidden" name="eDate" value="<?php echo($eDate);?>">
<input type="hidden" name="phone" value="<?php echo($phone);?>">
<input type="hidden" name="flag" value="2">
<script language="JavaScript">
function submitform()

Any suggestion? I can pass the values as:

But when the number of variables increases its hard to maintain.


5:37 am on May 23, 2007 (gmt 0)

WebmasterWorld Senior Member vincevincevince is a WebmasterWorld Top Contributor of All Time 10+ Year Member

You need to have a SUBMIT type INPUT element to automatically sumbit the form in many browsers.

<input type="submit" style="width:0px;height:0px" value="">

Something like that should work fine.

For passing lots of variables, consider using an array... <input name="something[]" type="hidden" value="1">
<input name="something[]" type="hidden" value="2">
<input name="something[]" type="hidden" value="3">

That gives you, on your server side, something[0], something[1], something[2]


2:01 pm on May 24, 2007 (gmt 0)

5+ Year Member

All form elements values are transmited on submit, even hidden fields. What is you problem?

Featured Threads

Hot Threads This Week

Hot Threads This Month