Click to See Complete Forum and Search --> : error in netscape


megan321
08-02-2003, 10:10 PM
can someone tell me what is wrong with this - it works in ie but causes an error in older netscape (I am just learning )~megan

code:--------------------------------------------------------------------
<!--- check to see if radio button (isDisplayed) is checked and if not the set hidden field value to 0 --->

<script language="JavaScript">

function change_status()

//see if radio button is checked
{for (i = 0; i < Articles.isDisplayed.length; i++)

{if(!document.Articles.isDisplayed[i].checked){document.Articles.Store1.value="0";
}

{if(!document.Articles.isDisplayed[i].checked){document.Articles.Store2.value="0";
}

{if(!document.Articles.isDisplayed[i].checked){document.Articles.Store3.value="0";
}
}//end

}//end

}//end


}//ends function

</script>

-----------------------------------------------------------------------

then

code:-------------------------------------------------------------------
<!--- store the value of the selected radio button in a hidden input, whenever a radio button is selected it's value is stored in the hidden input. --->

<input type="radio" name="isDisplayed" value="1" onClick="change_status();document.Articles.Store1.value=this.value;">
<input type="hidden" name="Store1" value="0" />

<input type="radio" name="isDisplayed" value="1" onClick="change_status();document.Articles.Store1.value=this.value;">
<input type="hidden" name="Store2" value="0" />

<input type="radio" name="isDisplayed" value="1" onClick="change_status();document.Articles.Store1.value=this.value;">
<input type="hidden" name="Store3" value="0" />

------------------------------------------------------------------------

Khalid Ali
08-02-2003, 10:26 PM
IE teaches developers bad habits,if you want to write code that have better chance of being used for a variety of browsers,you should always reference a form element in this manner

document.formName.elementName.attributeName

follow the above and it will work in most browsers(including NS)

megan321
08-02-2003, 10:37 PM
I'm confused -

document.formName.elementName.attributeName

I thought that's what I was doing:
document.Articles.isDisplayed[i].checked

document, the formname is Articles, and the elementname (radio button group) isDisplayed and its attribut whether or not it is checked

(same with document.Articles.Store2.value="0")

if these are not right, what should they be??? thanks megan

btw, the storing of the value in the hidden field works great in both ie and ns, its the checking and reseting to 0 that throws the error

Khalid Ali
08-02-2003, 10:43 PM
look in the loop code for you js

megan321
08-02-2003, 10:48 PM
Khalid, thank you SO much - I really appreciate it. ~megan

PS (and I will remember this tip about netscape!)

Khalid Ali
08-02-2003, 10:49 PM
:D
my pleasure...