homepage Welcome to WebmasterWorld Guest from 107.20.37.62
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Visit PubCon.com
Home / Forums Index / Browsers / Firefox Browser Usage and Support
Forum Library, Charter, Moderators: incrediBILL

Firefox Browser Usage and Support Forum

    
Problem across browsers in submitting form through Javascript
IndiaMaster




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

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.....

 

tedster




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

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.

IndiaMaster




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

Hi,

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

Can anyone help me out?

Achernar




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

What about :
document.forms['form-name'].submit();
or
document.forms[form-num].submit();

IndiaMaster




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

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">
</form>
<script language="JavaScript">
function submitform()
{
document.forms['f1'].submit();
}
submitform();
</script>

Any suggestion? I can pass the values as:
$url="search_cdr_result.php?sDate=".$sDate."&eDate=".$eDate."&phone=".$phone."&flag=2";

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

vincevincevince




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

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]

Achernar




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

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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Browsers / Firefox Browser Usage and Support
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved