NameSilo

Need help with JavaScript please!

Spaceship Spaceship
Watch

cesarian

Established Member
Impact
2
Hi, I have made a JavaScript that works well with Firefox but now with IE. Please help me.

Code:
function texton() {
	if ((document.forms['form1'].elements['q1'][0].checked) &&
     (document.forms['form1'].elements['q2'][0].checked) &&
     (document.forms['form1'].elements['q3'][0].checked) &&
     (document.forms['form1'].elements['q4'][0].checked) &&
     (document.forms['form1'].elements['q5'][0].checked)) {
		document.getElementById("form2").style.display = "";
	}
	else if((document.forms['form1'].elements['q1'][1].checked) ||
		      (document.forms['form1'].elements['q2'][1].checked) || 
		      (document.forms['form1'].elements['q3'][1].checked) || 
		      (document.forms['form1'].elements['q4'][1].checked) ||
		      (document.forms['form1'].elements['q5'][1].checked)){
		alert ("You must answer Yes on all questions before you can continue!"); 
		document.getElementById("form2").style.display = "none";
		return false;
	}
	else{
		alert ("You must answer all questions!");
		document.getElementById("form2").style.display = "none";

	}
	return false;
}
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
Code:
document.getElementById("form2").style.display = "";
Is this supposed to be blank? My guess is that it should be block.

Also, can you tell what isn't working about it.
 
0
•••
Yes, it should be blank. At this code below when all q1[0] to q5[0] checked, the hidden content should be unhidden.
Code:
if ((document.forms['form1'].elements['q1'][0].checked) &&
     (document.forms['form1'].elements['q2'][0].checked) &&
     (document.forms['form1'].elements['q3'][0].checked) &&
     (document.forms['form1'].elements['q4'][0].checked) &&
     (document.forms['form1'].elements['q5'][0].checked)) {
		document.getElementById("form2").style.display = "";
	}

and at this code below the hidden content will stay hidden and there is an alert that you must answer yes on all questions.
Code:
else if((document.forms['form1'].elements['q1'][1].checked) ||
		      (document.forms['form1'].elements['q2'][1].checked) || 
		      (document.forms['form1'].elements['q3'][1].checked) || 
		      (document.forms['form1'].elements['q4'][1].checked) ||
		      (document.forms['form1'].elements['q5'][1].checked)){
		alert ("You must answer Yes on all questions before you can continue!"); 
		document.getElementById("form2").style.display = "none";
		return false;

The code don't work at all at Internet Explorer, the hidden content are still hidden and no alert at all. The code works well at Firefox. Please take a look at http://www.carbrokers.com.au/page_layout_2_2.htm
 
0
•••
Please help me.
 
0
•••
Please help me.
 
0
•••
What is it doing in one that it wont do in the other?
 
0
•••
I don't know why it don't work in IE. That's way I need help.
 
0
•••
If you want it to be unhidden, you shouldn't just leave it blank, it should be:

Code:
document.getElementById("form2").style.display = "inline";
or

Code:
document.getElementById("form2").style.display = "block";


See if that does anything.

Even in firefox it gives you a console error in js debugger if the display is just left blank. Have you got a url to the problem page? Ill run my ie js debugger, see what it says.
 
Last edited:
0
•••
the question was...what do you mean by 'its not working'?
 
0
•••
The whole script don't works. It's look like that IE doesn't read function texton. I have tried to make an alert that read the value of the form but it wouldn't read the value. It is working with with FireFox, please check at http://www.carbrokers.com.au/page_layout_2_2.htm.
 
0
•••
Would someone please help me?
 
0
•••
Dynadot โ€” .com Registration $8.99Dynadot โ€” .com Registration $8.99
Unstoppable Domains
Domain Recover
DomainEasy โ€” Zero Commission
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back