Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript thread: Having problems with using variable in naming convention


Message #1 by "John Espinosa" <johndanielespinosa@y...> on Thu, 9 May 2002 01:28:25
Hi !

Try to print out element.value before you using 
document.TechEmail.[element.value].value;
and second I think you have extra dot.
try this :
document.TechEmail[element.value].value;
since TechEmail is a collection .

If you need to use dot you should use then this 
eval('document.TechEmail.' + element.value + '.value');

Hope this will help.

Oleg.


-----Original Message-----
From: John Espinosa [mailto:johndanielespinosa@y...]
Sent: May 08, 2002 9:28 PM
To: javascript
Subject: [javascript] Having problems with using variable in naming
convention


I have the value of a checkbox the same name as the name of a hidden 
field. I want to make the hidden field's value appear in a textfield 
dynamically each time the checkbox is clicked and erased when it is 
unchecked.

I cannot seem to get the name of the checkbox that is clicked turned over 
the the name of the hidden field.

Can anyone help please?

Thanks,
John Espinosa

<Script Language="Javascript">
function getInfo(element){
	 if(element.checked){
			document.TechEmail.Email.value += 
document.TechEmail.[element.value].value;      //if I can work this out 
then I will be able to erase it as well....
	 }else if(!element.checked){
 	 	document.TechEmail.Email.value = 
document.TechEmail.Email.value.replace(element.value,"")
	 }
	
}		

</Script>

---

Improve your web design skills with these new books from Glasshaus.

Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
r-20

  Return to Index