johnnyi
06-21-2005, 01:57 PM
I'm trying to write a JavaScript to assign a value to a textbox (TQScore) based on the selection from a dropdown (TQResult). For example, if the user selects "PM" from the dropdown, I want the textbox to display a "2". Whats happening is that, regardless of selection, when the function is executed, the dropdown itself is being set to "FE" and the textbox is being assigned the value of 5.
I tried to copy the value of the dropdown into a hidden textbox, and perform the script based on the value of that textbox, but it just overwrites the textbox with "FE" and assigns a score of 5.
What it appears to be doing in the if statement is setting the TQResult value to "FE" - ignoring the if statement and just performing the action (document.forms[0].TQResult.value = "FE").
How can I set this up to be a true if statement: whereas IF the value of the TQResult dropdown is equal to "PM" (for example), then set the TQScore value to a 2... and so on...
if (document.forms[0].TQResult.value = "DNM")
{
document.forms[0].TQScore.value = "1";
}
if (document.forms[0].TQResult.value = "PM")
{
document.forms[0].TQScore.value = "2";
}
if (document.forms[0].TQResult.value = "M")
{
document.forms[0].TQScore.value = "3";
}
if (document.forms[0].TQResult.value = "E")
{
document.forms[0].TQScore.value = "4";
}
if (document.forms[0].TQResult.value = "FE")
{
document.forms[0].TQScore.value = "5";
}
I tried to copy the value of the dropdown into a hidden textbox, and perform the script based on the value of that textbox, but it just overwrites the textbox with "FE" and assigns a score of 5.
What it appears to be doing in the if statement is setting the TQResult value to "FE" - ignoring the if statement and just performing the action (document.forms[0].TQResult.value = "FE").
How can I set this up to be a true if statement: whereas IF the value of the TQResult dropdown is equal to "PM" (for example), then set the TQScore value to a 2... and so on...
if (document.forms[0].TQResult.value = "DNM")
{
document.forms[0].TQScore.value = "1";
}
if (document.forms[0].TQResult.value = "PM")
{
document.forms[0].TQScore.value = "2";
}
if (document.forms[0].TQResult.value = "M")
{
document.forms[0].TQScore.value = "3";
}
if (document.forms[0].TQResult.value = "E")
{
document.forms[0].TQScore.value = "4";
}
if (document.forms[0].TQResult.value = "FE")
{
document.forms[0].TQScore.value = "5";
}