Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting a form ID

Status
Not open for further replies.

sanjs

Technical User
Mar 2, 2003
28
GB
Hi,

I'm trying to set the value of a form from a script, I'm using this to set the field to change:

setvdunits1(vunits1)

And here is the script,

function setvdunits1 (elname) {
felname = elname ;
var list = document.form1.mlselecta;
var listItemText = list.options[list.selectedIndex].text;
if (listItemText == "Fault")
{alert("wererwer");
(document.form1.felname.value = "y")}
}
else
alert("OK");
}


I keep getting an error 'vunits1 is undefined'

Can anyone please help!

Regards,

Sanj
 
well looks like you didnt define it to me to, good eye IE..lol

try this:

<script>
functiion chng(){
document.form[0].MyTextBox.value="hi";
}
</script>

use this to reference...learn how to incorporate this in your script...hint...no need to do this Function(somename), only do that when specifying vars in scripts which will be addressed in the body...

__________________________________________________________
"The only difference between me and a mad man is that I'm not mad."
- Dali
 
Try this to call the function:
Code:
setvdunits1(document.form1.vunits1);
This for the function:
Code:
function setvdunits1 (elname) {
    var list = document.form1.mlselecta;
    var listItemText = list.options[list.selectedIndex].text;
        if (listItemText == "Fault") {
            alert("wererwer");
            elname.value = "y";
        } else {
            alert("OK");
        }
}
 
your too nice Supra...let the new guys do some of the work themselves...lol

__________________________________________________________
"The only difference between me and a mad man is that I'm not mad."
- Dali
 
Thanks Supra and codeone, for this it works perfectly!

Regards,

Sanjay
 
your welcome sanjs, sorry I wasn't more helpful, it's just more fun to figure it out on your own, I think, however, frustrating!! ;)

glad you got it working!

______________________________________________________________________________
"The sluggard does not plow after the season, so he begs during the harvest and has nothing."
-[Proverbs 20:4]


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top