Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-05-2012, 10:29 AM   PM User | #1
davidwhite
New Coder

 
Join Date: Nov 2011
Posts: 27
Thanks: 4
Thanked 0 Times in 0 Posts
davidwhite is an unknown quantity at this point
Problem with Internet Explorer

Hello,

I have some code that relates to drop downs - kind of a pricing calculator.

It works fine on every other browser but doesn't work on Internet Explorer. (I'm using version 9).

The code is:

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>test</title>

<script>

function texter()
{
var textField;
textField = combo_3.value;
textFieldLength = combo_3.value.length;

if (textFieldLength==0)
{
combo_3.value=prompt("Please enter something","");
}
else
{ 
result.innerHTML = textField;
}

}

	data_1 = new Option("Black", "$");

	data_1_1 = new Option("Small", "-");
	

	data_1_1_1 = new Option("Quantity 80", "*");
		
data_1_1_1_1 = new Option("Standard","The price is $20");

	

    displaywhenempty=""
    valuewhenempty="<strong>Please choose an option from every dropdown</strong>"

    displaywhennotempty=""
    valuewhennotempty="<strong>Please choose an option from every dropdown</strong>"


function change(currentbox) {
	numb = currentbox.id.split("_");
	currentbox = numb[1];

    i=parseInt(currentbox)+1

while (document.getElementById("combo_"+i)) {
son = document.getElementById("combo_"+i);

for (m=son.options.length-1; m>0; m--) son.options[m]=null;

son.options[0]=new Option(displaywhenempty,valuewhenempty);
i++;
}

stringa='data';
i=0;
while (document.getElementById("combo_"+i)) {
stringa=stringa+'_'+document.getElementById("combo_"+i).selectedIndex;
if (i==currentbox) break;
i++;
}



    following=parseInt(currentbox)+1

  if (document.getElementById("combo_"+following)) {
son = document.getElementById("combo_"+following);
stringa=stringa+"_";
i=0;
while ((eval("typeof("+stringa+i+")!='undefined'")) || (i==0)) {

if ((i==0) && eval("typeof("+stringa+"0)=='undefined'"))
if (eval("typeof("+stringa+"1)=='undefined'"))
son.options[0]=new Option(displaywhenempty,valuewhenempty);
else
son.options[0]=new Option(displaywhennotempty,valuewhennotempty);
else
son.options[i]=new Option(eval(stringa+i+".text"),eval(stringa+i+".value"));
i++;
}

i=1;
combostatus='';
cstatus=stringa.split("_");
while (cstatus[i]) {
combostatus=combostatus+cstatus[i];
i++;
}
return combostatus;
}
}


function go(elementName){
var newUrl=document.forms[0].elements[elementName].options[document.forms[0].elements[elementName].selectedIndex].value;
if(newUrl.indexOf("www")>=0){
location.href=newUrl;
}
}

</script>


</head>

<body>
<form>

<table align="center" width="500" cellspacing="6" cellpadding="6">
<tr><td align="left" class="steps">Step 1 - Choose a color</td></tr>
<tr><td class="steps2"><select name="combo0" id="combo_0" onChange="change(this);" style="width:200px;">
<option selected="selected" value="value1"></option>
<option value="value2" id="p1">Black</option>
</select></td></tr><tr><td align="left" class="steps">Step 2 - Choose size</td></tr>
<tr><td class="steps2"><select name="combo1" id="combo_1" onChange="change(this)" style="width:200px;">
	<option value="value1">  </option>
</select></td></tr><tr><td align="left" class="steps">Step 3 - Choose quantity</td></tr>
<tr><td class="steps2"><select name="combo2" id="combo_2" onChange="change(this);" style="width:200px;">
	<option value="value1">  </option>
</select></td></tr><tr><td align="left" class="steps">Step 4 - Choose quality</td></tr>
<tr><td class="steps2"><select name="combo3" id="combo_3" onChange="change(this);" style="width:200px;">
<option value="value1">  </option></select></td></tr>

<tr><td><input type= "button" value = "Get your quote now" onclick = "texter()"> </td></tr>

<tr><td><div class="result" id="result"></div></td></tr>


</table>

</form>
</body>
</html>
Any help would be appreciated.

Thanks
davidwhite is offline   Reply With Quote
Old 09-05-2012, 11:13 AM   PM User | #2
Logic Ali
Regular Coder

 
Logic Ali's Avatar
 
Join Date: Sep 2010
Location: London
Posts: 959
Thanks: 0
Thanked 198 Times in 193 Posts
Logic Ali will become famous soon enoughLogic Ali will become famous soon enough
Try clicking on the yellow triangle in the corner.

I.E. doesn't know what you mean by 'combo_3'.
Logic Ali is offline   Reply With Quote
Old 09-05-2012, 02:53 PM   PM User | #3
davidwhite
New Coder

 
Join Date: Nov 2011
Posts: 27
Thanks: 4
Thanked 0 Times in 0 Posts
davidwhite is an unknown quantity at this point
Quote:
Originally Posted by Logic Ali View Post
Try clicking on the yellow triangle in the corner.

I.E. doesn't know what you mean by 'combo_3'.
Ok thanks.
davidwhite is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:43 AM.


Advertisement
Log in to turn off these ads.