/    Sign up×
Community /Pin to ProfileBookmark

foxfire issues with changing form values

so i have this line of code

[code]
document.this.that.value = “this and that”;
[/code]

when I submit it in IE the value changes to “this and that”, however when I submit it with firefox the value stays the same as it is originally written. I have looked over the web for a while and everything I read talks about “inner HTML” but doesnt seem to help me fix the problem.

How do I go about fixing this for firefox???

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@KorMay 26.2005 — it depends on what is the [b]real[/b] names for [i]this[/i] form and [i]that[/i] element. I suppose that you have used javascript used or reserved words for them (http://www.javascriptkit.com/jsref/reserved.shtml). The list is not exhaustive, and it might be some differences between IE and Mozila.

To avoid that, use the full square brackets notation:

document.forms['formname'].elements['elementname']

and avoid the used/reserved javascript words for names,id's, functions, variables, parameters.
Copy linkTweet thisAlerts:
@CharlesMay 26.2005 — It's more likely that your instance of Firefox has JavaScript disabled. A lot of people do that so expect your script to fail from tiome to time.

But it is also possible that you have some sort of HTML error that is causing Firefox to not recognize the script. Run the page through [url=http://validator.w3.org/]The Validator[/url].
Copy linkTweet thisAlerts:
@DARTHTAMPONauthorMay 29.2005 — the names are not keywords, I was just making an example without thinking.

My real issue is shown perfectly here

http://www.kokogiak.com/thatboxinthecorner/innerHTML_formvals.html

When I change a value, it is not passed to my php form destroying the validation work done with the page. How do I get around this so my javascript can talk to my php using firefox?
Copy linkTweet thisAlerts:
@VladdyMay 29.2005 — First, proper uses of innerHTML are very few and far in-between. Yours is certainly not one of them.

Second, you do not use client side for form data [b]validation[/b] - it can be easily bypassed.

Third, proper form data verification is done as follows
<i>
</i>&lt;form onsubmit="return verify(this)"&gt;
&lt;input name="someText" value="" /&gt;
&lt;/form&gt;
&lt;script type="text/javascript"&gt;
function verify(form)
{ // read &lt;input&gt; value:
var inputValue = form.elements['someText'].value;
// change &lt;input&gt; value:
form.elements['someText'].value = 'New Value';

<i> </i>if(/*form data ok*/) return true;
<i> </i>else return false;
}
&lt;/script&gt;
×

Success!

Help @DARTHTAMPON spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...