Change value of one variable based on user input of another value

T

TeknoShock

I am trying to use an if then in javascript to change one value based
on what a user inputs for another value. It is not working correctly.
Here is the relevant code:
---------------------------
<script language="javascript" >

function decideWhoToMailTo(dform) {
if (document.dform.ru.value == "122") {
document.dform.param_pie = "(e-mail address removed)";
} else if (document.dform.ru.value == "144") {
document.dform.param_pie = "(e-mail address removed)";
}

}

</script>
-----------------------------
<FORM name="dform"
ACTION="http://intranet.mycompany.org/cgi-bin/purchase2.pl" METHOD=POST

onsubmit="decideWhoToMailTo(this);" >

<INPUT TYPE="hidden" name="param_pie">


RU: <input type="text" name="ru" value="122" tabindex="2">
----------------------------
I then passed the param_pie to the cgi script just to see what it is
being set to. It is being set to blank.

Can you see where I went wrong? I am leaving the ru set to the default

value of 122, so I would expect param_pie to be set to (e-mail address removed).
 
V

VK

function decideWhoToMailTo(dform) {
if (document.dform.ru.value == "122") {
document.dform.param_pie = "(e-mail address removed)";
} else if (document.dform.ru.value == "144") {
document.dform.param_pie = "(e-mail address removed)";
}

}

</script>
-----------------------------
<FORM name="dform"
ACTION="http://intranet.mycompany.org/cgi-bin/purchase2.pl" METHOD=POST

onsubmit="decideWhoToMailTo(this);" >

<INPUT TYPE="hidden" name="param_pie">


RU: <input type="text" name="ru" value="122" tabindex="2">


1) dform is a direct reference to your form, no document reference is
needed.

2) form control value is changed over it .value property


<script type="text/javascript" >

function decideWhoToMailTo(dform) {
if (dform.ru.value == "122") {
dform.param_pie.value = "(e-mail address removed)";
} else if (dform.ru.value == "144") {
dform.param_pie.value = "(e-mail address removed)";
}
}

</script>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top