Sunday, November 29, 2009

Issue with javascript and IE vs FIREFOX using testfields.value?

i have 2 input fields as follows:



%26lt;INPUT TYPE=HIDDEN NAME="anskey" VALUE="ACDB" id="anskey"%26gt;



%26lt;INPUT TYPE=HIDDEN NAME="qnum" VALUE="1" id="qnum"%26gt;



NOTE that anskey is an array or chars.



i need to get the value of anskey[qnum-1] wich should be 'A'



in my javascript code i have the following:



var anskey = document.getElementById('anskey');



var qnum = document.getElementById('qnum');



if (anskey %26amp;%26amp; qnum %26amp;%26amp; uans != anskey.value[qnum.value-1])



alert('Your Answer (' + uans + ') was incorrect. You should have selected (' + anskey.value[qnum.value-1] + ')');



the refference to anskey.value[qnum.value-1] retuns 'A' in an alert on FIREFOX



in IE i get 'UNDEFINED'



if i just show anskey.value and qnum.value i'm able to display both properly



what am i doing wrong?



Issue with javascript and IE vs FIREFOX using testfields.value?microsoft office





You might want to try .substr(x,1) instead.



I don't have an IE here, so I can't test it, but what is the value of qnum.value-1 ?

No comments:

Post a Comment

 
loan