Quick question, I'm trying to pass a value to a variable and then run a function if the variable was set to something specific. How do I do that?
I have the following example where I want to assign the value name to a form field if the variable type is set to 1.
function test(name,type) {
if (type=1) {
document.myform.name.value = name;
}
}
and a link in the body of the html:
<a href="javascript:test('myname','1');">FILL IN MY NAME</a>
I also tried the following with no luck:
function test(name,type) {
var checktype = type;
if (checktype = 1) {
document.myform.name.value = name;
}
}
I'm pretty sure something like this is possible, just not sure what I'm doing wrong.