fl00d
03-06-2008, 01:21 AM
Hi,
I've got a really, really simple question, but I haven't found anything using Google yet. (most likely because I can't think of the right word)
I'm creating a very basic function that will enable form elements depending on whether or not a checkbox has been checked. Simple enough, right? I decided to go a bit farther and make this function a little more versatile by passing arguments, so I could use it for other pages and not have to name the form and elements the same.
function enableElement(form,element){
var formName = form;
var elementName = element;
if(document.formName.newbrand.checked == true){
document.formName.elementName.disabled = false;
}
}
MY problem is that I don't know how to write the document statement so that
document.formName interprets formName as a variable and not a string value. ANyone understand what I mean?
Like in php
1:echo 'this $string is printed literally'
2:echo "strings value is: $string".
#2 of the PHP example $string's contents wil be displayed instead of $string (literally). This is what I'm trying to do with the document.formName.elementName
Can someone tell me how?
I've got a really, really simple question, but I haven't found anything using Google yet. (most likely because I can't think of the right word)
I'm creating a very basic function that will enable form elements depending on whether or not a checkbox has been checked. Simple enough, right? I decided to go a bit farther and make this function a little more versatile by passing arguments, so I could use it for other pages and not have to name the form and elements the same.
function enableElement(form,element){
var formName = form;
var elementName = element;
if(document.formName.newbrand.checked == true){
document.formName.elementName.disabled = false;
}
}
MY problem is that I don't know how to write the document statement so that
document.formName interprets formName as a variable and not a string value. ANyone understand what I mean?
Like in php
1:echo 'this $string is printed literally'
2:echo "strings value is: $string".
#2 of the PHP example $string's contents wil be displayed instead of $string (literally). This is what I'm trying to do with the document.formName.elementName
Can someone tell me how?