Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set textfield value works fine in Firefox/ safari but not in IE

Status
Not open for further replies.

whappit

Programmer
Joined
Jun 2, 2006
Messages
4
Location
NL
hey there, im making a wk toto for my friends, I wanna make the following:
if score a1 > a2
set value(land1)...

var eindstanda1 = document.form1.textfield10.value;
var eindstanda2 = document.form1.textfield29.value;

var a1 = document.form1.select1.value;
var a2 = document.form1.select2.value;

if(eindstanda1 >= eindstanda2)
{
document.form1.s49.value = a1;
}

(s49) is the textfield where the country name comes.

In Firefox and Safari this works perfectly fine, in IE it doesnt, but if i replace a1 with a String it does. For example: document.form1.s49.value = "KUT";

I call the function with an onchange="" btw.

PS if i alert the value of a1 it alerts empty. while in both other explorers its alerts just fine
 
>I call the function with an onchange="" btw.
What do you mean?

>In Firefox and Safari this works perfectly fine, in IE it doesnt,
On the surface with what you posted sofar, the claim is of no merit, I think, unless you show further evidence.

 
first question:
<script type="text/javascript" language="JavaScript">
<!--
function hackland(){
//landen
var a1 = document.form1.select1.value;
var a2 = document.form1.select2.value;
var b1 = document.form1.select3.value;
var b2 = document.form1.select4.value;
var c1 = document.form1.select5.value;
var c2 = document.form1.select6.value;
var d1 = document.form1.select7.value;
var d2 = document.form1.select8.value;
var e1 = document.form1.select9.value;
var e2 = document.form1.select10.value;
var f1 = document.form1.select11.value;
var f2 = document.form1.select12.value;
var g1 = document.form1.select13.value;
var g2 = document.form1.select14.value;
var h1 = document.form1.select15.value;
var h2 = document.form1.select16.value;
//scores
var eindstanda1 = document.form1.textfield10.value;
var eindstanda2 = document.form1.textfield29.value;
var eindstandb1 = document.form1.textfield11.value;
var eindstandb2 = document.form1.textfield210.value;
var eindstandc1 = document.form1.textfield12.value;
var eindstandc2 = document.form1.textfield211.value;
var eindstandd1 = document.form1.textfield13.value;
var eindstandd2 = document.form1.textfield212.value;
var eindstande1 = document.form1.textfield14.value;
var eindstande2 = document.form1.textfield213.value;
var eindstandf1 = document.form1.textfield15.value;
var eindstandf2 = document.form1.textfield214.value;
var eindstandg1 = document.form1.textfield16.value;
var eindstandg2 = document.form1.textfield215.value;
var eindstandh1 = document.form1.textfield17.value;
var eindstandh2 = document.form1.textfield216.value;

if(eindstanda1 >= eindstanda2)
{
document.form1.s49.value = a1;
}
}
//-->
</script>

callout:
<input name="textfield29" type="text" size="2" maxlength="2" onchange="hackland();" />

Further evidence? ye need screenshots? Textfield s49 perfectly gains the value of a1 in Firefox and Safari, but it remains empty in IE. if I alert the value in both other browsers it has a value and in IE it's empty...
 
Further evidence? ye need screenshots?
No, evidence of your good judgement of what is essential and what not.
[tt]
<html>
<head>
<script language="javascript">
function doit() {
var eindstanda1 = document.form1.textfield10.value;
var eindstanda2 = document.form1.textfield29.value;
alert(eindstanda1+"\n"+eindstanda2+"\n"+(eindstanda1 >= eindstanda2));
var a1 = document.form1.select1.value;
var a2 = document.form1.select2.value;
alert(a1+"\n"+a2);
if(eindstanda1 >= eindstanda2)
{
document.form1.s49.value = a1;
}
}
</script>
</head>
<body>
<form name="form1">
<input type="text" name="textfield10" value="3" /><br />
<input type="text" name="textfield29" value="2" /><br />
<input type="text" name="s49" value="1" /><br />
<select name="select1" onchange="doit()">
<option value="a">a</option>
<option value="b">b</option>
<option value="c">c</option>
<option value="d">d</option>
</select>
<select name="select2"> <!-- this is of no use yet -->
<option value="aa">aa</option>
<option value="bb">bb</option>
<option value="cc">cc</option>
<option value="dd">dd</option>
</select>
</form>
</body>
</html>
[/tt]
You now show you have onchange on a text field, that is already a new piece of material info. What do you think the audience can know by solely mentioning onchange equal to empty string ("")?
 
Hmm imho opinion the audience now has all the info it needs, if not feel free to ask. But do you have any clue why this script does work on Firefox and it doesnt on IE? any standard things that tend to go wrong in that case?
 
You want the forum to give you what you want: yes ie is non-standard compliance here and there. But, in this case, no; and that's why I say the claim has no merit in your case as presented. (I don't mean your works have no merit, just the limited scope of that claim as presented.) Maybe other can give you satisfaction.
 
Hmmm, i fonally found out what the trouble is.

In IE Javascript doesnt take the value of a field when it is solely added with <option>blabla</option>
you need to give it a value too like <option value='blabal'>blabla</option>

Thanks for your help guys, much appreciated. Note that in firefox and other good browser this doesnt happen
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top