...

View Full Version : Varibles are defined in IE, but page does not work in firefox/NS/Opera!!



Drsuave
04-19-2005, 06:52 PM
Hi all,

Bit of help needed have been trying to figure out this problem for a few days.

The problem:

When the page is run in IE and the user goes though to the next page the correct varibles:

action=buy_spanstor&products_id=2619:1,1092:1,4797:1

:)

But when it is run in Firefox, Opera or Netscape the varibles come out as:

action=buy_spanstor&products_id=2619:1,undefined:1,undefined:1

:(

I am very confussed to why this is. Theories include have variables are declared and many other thinks but i can find no solution!!!

The problem variables are CASEpid and HDpid.

I have striped down the code to the basics and have attached them as a txt file and printed them below.

Can any one help? Please..... :confused:

<script>var i, HDpid, HDprice, HDtext, CASEpid, CASEtext;

function popupWindow(url) {
window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars =no,resizable=yes,copyhistory=no,width=100,height=100,screenX=150,screenY=150,top=150,left=150') }

function display(numb){ if (parseFloat(numb)){
if (numb== Math.round(numb)){ return ( numb + ".00") } else { numb=(numb + "0");
return (numb.substring(0,(numb.indexOf(".")+3))) } } else{ return "0.00" } }

function lv(List) { return(List.options[List.selectedIndex].value); }
function lt(List) { return(List.options[List.selectedIndex].text); }
function la(List) { return(List.options[List.selectedIndex].alt); }

function ChangeDisk(form){
HDprice=lv(form.Disk); HDtext=lt(form.Disk); HDpid=la(form.Disk); pricechange(form); }

function pricechange(form) {
var price=0;
for (i = 0 ; i < form.optioncase.length ; i++)
{ if (form.optioncase[i].checked)
{ if (HDprice>1) { price = 1*form.optioncase[i].value + 1*(HDprice);
CASEpid = form.optioncase[i].pid; CASEtext = form.optioncase[i].alt;
break; } } }

if (price>0) { form.price.value=display(price); form.priceVAT.value=display(price*1.175);
form.Description.value=CASEtext + " with " + HDtext; }
else { form.price.value = form.priceVAT.value = form.Description.value = "Choose Case + Drive"; }
return(price); }

function buyStorage(form) {
if (form.price.value>0) {
self.location.href = "FAKE.php?cPath=31_32&action=buy_spanstor&products_id=2619:1,"+CASEpid+":"+"1"+","+HDpid+":"+"1";
}
}
</script>

<form>
USB2<br><input type="radio" name="optioncase" alt="IB-U2g3" pid="4369" value="29.0000" onclick="pricechange(this.form)">
<br>Firewire<br><input type="radio" name="optioncase" alt="IB-Fic" pid="1079" value="54.0000" onclick="pricechange(this.form)">
<br>USB2 + Firewire<br><input type="radio" name="optioncase" alt="IB-U2Fg3" pid="4367" value="39.0000" onclick="pricechange(this.form)">
<br>
<select name="Disk" onChange="ChangeDisk(this.form)">
<option value="0" alt="0" selected>Select from the drop down...</option>
<option value="31.0000" alt="1271">40gb, 7200rpm, 2mb : Seagate Barracuda 7200.7 ST340014A U100 </option>
<option value="37.0000" alt="1188">80gb, 7200rpm, 2mb : Maxtor DiamondMax +9 6Y080L0 U133 </option>
<option value="38.0000" alt="1192">80gb, 7200rpm, 8mb : Maxtor DiamondMax +9 6Y080P0 U133 </option>
</select>
<BR><BR>
<textarea cols=55 rows=2 name="Description" ReadOnly onChange="pricechange(this.form)"></textarea><br>
<input type="price" name="price" value="0.00" ReadOnly onChange="pricechange(this.form)" size="22">
<input type="price" name="priceVAT" value="0.00" ReadOnly onChange="pricechange(this.form)" size="22">
<input type="button" name="buynow" value="Add to basket" onClick="buyStorage(this.form);">
</FORM>

Drsuave
04-19-2005, 07:05 PM
Sorry did not post the txt file.

glenngv
04-20-2005, 06:09 AM
To access custom attributes, you need to use getAttribute method.

CASEpid = form.optioncase[i].getAttribute("pid");


But if I were you I would just put pid and alt in the value attribute because custom attributes are not standard.

<input type="radio" name="optioncase" value="39.0000~IB-U2Fg3~4367" onclick="pricechange(this.form)">
...
function pricechange(form)
{
var price=0;
var radioVal;
for (i = 0 ; i < form.optioncase.length ; i++)
{
if (form.optioncase[i].checked)
{
if (HDprice>1)
{
radioVal = form.optioncase[i].value.split("~");
price = 1*radioVal[0] + 1*(HDprice);
CASEpid = radioVal[2];
CASEtext = radioVal[1];
break;
}
}
}
...
}

Drsuave
04-20-2005, 12:07 PM
Legend. Have it all working now cheers!!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum