Forum Moderators: open

Message Too Old, No Replies

Works just in IE

other browsers ignore JS

         

grandpa

7:49 pm on Oct 20, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



My javascrpt works like a charm in IE, but when I test it with any other browser it just sits there, no results and more important, no sales.

I know that different browsers treat JS differently. I couldn't find what I needed to test a browsers compatablilty. Any suggestions?

DrDoc

7:55 pm on Oct 20, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Most likely you're using document.all style syntax. You should be using document.getElementByID instead (or in addition to)...

grandpa

8:58 pm on Oct 20, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Here's a snippet:

function GetSelect (form) {
alert("got here");
alert(Item);
Item = Add.VARname.selectedIndex;
Result = Add.VARname.options[Item].text;
Result2 = Add.VARname.options[Item].value;
T = Add.VARname.options[Item].text;
T2 = Add.VARname.options[Item].value;
fillform()

I get the first alert, the alert for "Item" shows up, but its empty (NULL?). So the browsers don't seem to like my Item = Add.VARname.selectedIndex statement. If I move the Item alert below the "Item =" line, I get nothing, no alert, nada. Looks to me like thats where its breaking.

You should be using document.getElementByID

My functions seem to be using this. In part:

document.getElementById("AddSubmit").disabled = false;}
and
document.getElementById("AddSubmit").disabled = true;

But those lines simply control whether my Add To Cart button is or is not active.

MonkeeSage

9:13 pm on Oct 20, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What are 'Add' and 'VARname'? I'm assuming that 'VARname' is the name of the select box but where does 'Add' come from? You might just need to replace the 'Add' with 'form', or prefix it with 'document.', but it's hard to tell without a bit more context.

Jordan

grandpa

9:25 pm on Oct 20, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



What are 'Add' and 'VARname'

Add is the name of my form: <form name="Add">

VARname is my select name: <select name="VARname" size="1">

I tried to validate this page yesterday with Transitional standards, and the form was one of the problems that cropped up, because there was no method. The form contains my selections, 2 buttons (one to add items from the options list, the other to clear the selections. Finally it has 4 text boxes to display items selected.

MonkeeSage

9:30 pm on Oct 20, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I was thinking that might be the case. I think 'document.Add.VARname...' will let it work in the other browsers as well.

Jordan

grandpa

11:02 pm on Oct 20, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Adding document. to my variable helped. I have one problem remaining.

My Add to Cart button is disabled until 4 items are picked.

<input src="/images/addbotton.gif" name="AddSubmit" type="image" align="middle" style="width:58;height:20;border:0" disabled="TRUE" onClick="SubmitSelect()">

I'm counting the items as they are picked with (var i=1;), and my fillform() function has this line to enable the "AddSubmit"

{if (i == 4) document.Add.T4.value = T; TArray[3] = T; TArray2[3] = T2; ++i;
document.getElementById("AddSubmit").disabled = false; }

"AddSubmit" never gets its state modified, it remains disabled. I tried substituting document. with form. and false with 0. I tried UPPER CASE and lower case, I tried "quotes" and no quotes. The ugly button just sits there defying my efforts.

grandpa

11:20 pm on Oct 20, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I fixed the last problem, with the AddSubmit button state. The name may have been the problem, perhaps because it was not the first element listed:

<input src="/images/addbotton.gif" name="AddSubmit" type="image" align="middle" style="width:58;height:20;border:0" disabled="TRUE" onClick="SubmitSelect()">

I re-wrote that line to read , in part:
<input name="AddSubmit" id="Addsubmit" ... not sure yet if the id played a role, or just because I moved the name.