how to escape a varialbe in an element declaration.
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Johnny_Grimes
Posted On:   Tuesday, November 18, 2003 06:25 AM

I have the following function: function toggleCustomComment(id, chosen) { if (chosen == 'Custom Comment') { document.tapeSelectForm.id.disabled = false; document.tapeSelectForm.id.value = "N/A"; debug('In if'); } else { document.tapeSelectForm.id.disabled = true; document.tapeSelectForm.id.value = "N/A"; debug('In else'); } The problem is that in the statement: document.tapeSelectForm.id.disabled = false; id is being interpreted as an element name, I need it to be interpreted as the variable t   More>>

I have the following function:



function toggleCustomComment(id, chosen)

{

if (chosen == 'Custom Comment')

{

document.tapeSelectForm.id.disabled = false;

document.tapeSelectForm.id.value = "N/A";

debug('In if');

}

else

{

document.tapeSelectForm.id.disabled = true;

document.tapeSelectForm.id.value = "N/A";

debug('In else');

}




The problem is that in the statement:
document.tapeSelectForm.id.disabled = false;

id is being interpreted as an element name, I need it to be interpreted as the variable that was passed to the function. I have tried entering it with single and double quotes and also escaping it with /. None of those seem to work. I'm a beginner, any ideas?

   <<Less

Re: how to escape a varialbe in an element declaration.

Posted By:   Firat_Tiryaki  
Posted On:   Friday, November 21, 2003 07:28 AM

use the below code in your function




formelement=eval("document.tapeSelectForm."+id);
formelement.disabled=true;
About | Sitemap | Contact