/    Sign up×
Community /Pin to ProfileBookmark

Help with auto fill please!

Please Help with following code.
works in Netscape but not IE.

eval() not used correctly!

[code]
function AutoFill(FormName,SelectName,TargetName) {
var v = document.eval(FormName).eval(SelectName).selectedIndex;
var Output = document.eval(FormName).eval(SelectName).options[v].text;
if (Output > 1){
document.eval(FormName).eval(TargetName).value = “Yes”
}
else if (Output == “—“) {
document.eval(FormName).eval(TargetName).value = “No”
}
else {
document.eval(FormName).eval(TargetName).value = “No”
}
}

<form name=”MyForm”>
<input name=”MyInput” type=”text” size=”10″>
<select name=”MySelect” onchange=”AutoFill(‘MyForm’,’Myselect’,’MyInput’)”>
<option>—
<option>1
<option>2
<option>3
</select>
</form>
[/code]

Basically, what is the correct coding for:

[code]
document.eval(FormName).eval(SelectName).selectedIndex
[/code]

I know that eval() is not the correct way to code this but I haven’t been able to figure out the correct way.

Thanks,

Beetleman

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@beetlemanauthorMar 29.2003 — Thanks Dave.

I had a little trouble though.

I was using this.form and as you already know, that didn't work!

Changed to this.form.name and success!

From other posts in the forum, I knew that "eval()" wasn't correct but when I tried the correct way before it didn't work because of the "this.form" problem.

Thanks again, everything works just fine in both NS and IE. Will contact my aol buddies to have them try it in the aol browser. I'll need to install Opra and check its compatability as well.

Am I missing any major browsers?

Beetleman
×

Success!

Help @beetleman 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.2,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...