PDA

View Full Version : URGENT - properties in netscape


javelin
03-26-2001, 02:14 PM
Anyone know the syntax cheapscape uses to address items in a form?

ex. In IE I can write:
...
var ch = document.forms[0].elements;
var l = document.forms[0].length;
var ls_type = type + "";
var lb_checked=false;


if (ch!=null) {
for (var i=0; i<ch.length; i++) {
if( (ch.item(i).tagName == "INPUT") && (ch.item(i).id.indexOf(ls_type) != -1) ){
if(ch.item(i).checked)
lb_checked =true;
}
}// end for
}// end if

and get each elements values with no prob. Netscape doesn't recognize any of this - it tells me that forms have no properties.

So how do get the values of dynamically generated INPUTs in a form in cheapscape?

Thanx :)

Dr. Web
03-26-2001, 04:00 PM
Can you post the URL of the page conatining the form? Thanks

Marlboro
03-26-2001, 04:45 PM
You'll need to follow NS DOM for accessing form elements....
this supposes that the element is in the 1st form in your document: (counting starts at 0)

document.forms[0].elementname.value

and if its in a layer (or DIV) then it becomes a bit more complicated:

document.layername.document.forms[0].elementname.value

and if its a select element (<select>) and you want to obtain a value, or text, or indexvalue or something of that nature of the selected item then its even more convuluted:

document.formname.selectname.options[document.formname.selectname.selectedIndex].text

and if that select element is a form thats in a layer then

document.layername.document.formname.selectname.options[document.formname.selectname.selectedIndex].text

you CAN replace forms[0] with formname and vice versa as shown in the last example

I know this didnt answer you exactly - but hopefully it did help you out some. I'll see if I can find my code for iterating thru form elements later when I'm not so busy.

javelin
03-28-2001, 09:08 AM
Thanks.

I got it with this code:
function gf_Check_RB(ps_NomRb) // iterate and check radio btns
{
var ch = document.forms[0].elements;
var li_Len = ch.length;
var lb_checked=false;

for (var i=0; i<li_Len; i++) {
if(ch[i].name.indexOf(ps_NomRb)!=-1){
if(ch[i].checked){
lb_checked=true;
break;
}
}
}

return lb_checked;
}

NS doesn't support the item property or the id property so you have to use name