Problem on Safari version 1.0.3

V

vikesfan

I have the following code in my page:

function formSubmit(next){
document.forms[0].button.value = next;
document.forms[0].userAgent.value = navigator.userAgent;
document.forms[0].submit();
}


When I hit the submit button which runs this code none of the form
fields are populated. when I try to pull them out in my Java code they
are empty. Any idaes? Thanks.
 
T

Thomas 'PointedEars' Lahn

vikesfan said:
I have the following code in my page:

function formSubmit(next){
document.forms[0].button.value = next;
document.forms[0].userAgent.value = navigator.userAgent;
document.forms[0].submit();
}


When I hit the submit button which runs this code none of the form
fields are populated. [...]

"Does not work" is a useless error description. [psf 4.11]

Read the FAQ, especially <URL:http://jibbering.com/faq/#FAQ4_43> and
try the standards compliant approach:

document.forms[0].elements['button'].value = next;
document.forms[0].elements['userAgent'].value = navigator.userAgent;

It also is highly likely that you have a control named `submit' which
overrides/overwrites the submit() method. In that case you should see a
TypeError exception ("submit is not a function") on the submit() line.


HTH

PointedEars
 
R

Randy Webb

Thomas 'PointedEars' Lahn said the following on 3/11/2006 5:18 PM:
vikesfan said:
I have the following code in my page:

function formSubmit(next){
document.forms[0].button.value = next;
document.forms[0].userAgent.value = navigator.userAgent;
document.forms[0].submit();
}


When I hit the submit button which runs this code none of the form
fields are populated. [...]

"Does not work" is a useless error description. [psf 4.11]

Then it's a good thing he didn't say that then, huh?
Read the FAQ, especially <URL:http://jibbering.com/faq/#FAQ4_43> and
try the standards compliant approach:

document.forms[0].elements['button'].value = next;
document.forms[0].elements['userAgent'].value = navigator.userAgent;

There is nothing more "standards compliant" about what you posted than
what the OP posted. Both are equally "compliant". If want to nit-pick it
into compliance, then don't mix numeric indexes and string indexes:

document.forms['formID'].elements['userAgent'].value;
 
L

Lasse Reichstein Nielsen

Randy Webb said:
Thomas 'PointedEars' Lahn said the following on 3/11/2006 5:18 PM:
vikesfan said:
document.forms[0].button.value = next;
document.forms[0].elements['button'].value = next;
There is nothing more "standards compliant" about what you posted than
what the OP posted. Both are equally "compliant".

No need to put "compliant" in quotes[1].

The specification is not entirely clear on this point. There is no
doubt that what Thomas Lahn wrote is only relying on features
standardized by the W3C HTML DOM (even in version 1) ECMAScript
bindings.

There is doubt that the named controls should be made available as
properties of the form element itself, and not just as properties of
the elements collection. Doing so is unnecessary (since the elements
collection is specified) and it is likely to lead to name collisions
between form controls and properties and methods of the form
element. It is, however, what most brosers have done, leading
to the recurring problem of "form.submit() doesn't work .. oh, the
submit button is named 'submit'".

/L
[1] Damn, now I did it!
 
T

Thomas 'PointedEars' Lahn

Lasse said:
Randy Webb said:
Thomas 'PointedEars' Lahn said the following on 3/11/2006 5:18 PM:
vikesfan wrote:
document.forms[0].button.value = next;
document.forms[0].elements['button'].value = next;
There is nothing more "standards compliant" about what you posted than
what the OP posted. Both are equally "compliant".

No need to put "compliant" in quotes[1].

The specification is not entirely clear on this point.

It is. The HTMLFormElement interface provides no `button' property, for
example. So that property would not be part of that Web standard, but
proprietary; a proprietary extension, if you will.


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

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top