469,947 Members | 2,176 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,947 developers. It's quick & easy.

Accesing object properties programatically

I have an event where attendants can register for online. This is 2 day event. I want to be able to disable the same lab on day2 when it has been selected on day1 (so attendants don't select the same lab on two different days).
This is the function I am using...

[HTML]function DisableOther(a){
var myD = a.name.substring(4, 5);
var myS = a.name.substring(6, 7);
var othD;
if (myD == 1){
othD = '2';
} else {
othD = '1';
}
var b = eval("document.frm01." + a.name);
var c = findButton(b);
eval("document.frm01.optD" + othD + "S" + myS + "[" + c + "].disabled = true");
if (c == 0){
eval("document.frm01.optD" + othD + "S" + myS + "[" + (c + 1) + "].disabled = false");
} else {
eval("document.frm01.optD" + othD + "S" + myS + "[" + (c - 1) + "].disabled = false");
}
}
function findButton(buttonGroup){
for (i=0; i < buttonGroup.length; i++) {
if (buttonGroup[i].checked == true) {
return i;
}
}
}

<input type="radio" name="optD1S1" id="optD1S1" value="D1S1-1" onClick="DisableOther(this)" />
<input type="radio" name="optD1S1" id="optD1S1" value="D1S1-2" onClick="DisableOther(this)" />
<input type="radio" name="optD2S1" id="optD2S1" value="D2S1-1" onClick="DisableOther(this)" />
<input type="radio" name="optD2S1" id="optD2S1" value="D2S1-2" onClick="DisableOther(this)" />[/HTML]

I know I shouldn't use eval but I don't know how to access the properties of the radio button group.
The above code is working on IE but not working on FF, any ideas??
Thanks...
Jan 26 '08 #1
1 1134
gits
5,390 Expert Mod 4TB
hi ...

yes :) ... you shouldn't (and needn't) use eval ... have a look at the following example:

Expand|Select|Wrap|Line Numbers
  1. // we have a part of your id
  2. var id = 'optD1S';
  3.  
  4. // now we make the correct id (optD1S1)
  5. var node_id = id + 1;
  6.  
  7. // refer to the node with node_id
  8. var node = document.getElementById(node_id);
  9.  
  10. // setting the disabled attrib to disabled
  11. node.setAttribute('disabled', 'disabled');
  12.  
  13. // remove the attrib
  14. node.removeAttribute('disabled');
  15.  
kind regards
Jan 28 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by Jeroen Ceuppens | last post: by
5 posts views Thread by Ram [MSFT] | last post: by
7 posts views Thread by Martin Robins | last post: by
13 posts views Thread by Fernando Deutsch | last post: by
4 posts views Thread by sracherla | last post: by
6 posts views Thread by =?ISO-8859-1?Q?Ignacio_Burgue=F1o?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.