473,378 Members | 1,382 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

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

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 = "me@mycompany.org";
} else if (document.dform.ru.value == "144") {
document.dform.param_pie = "yo*@mycompany.org";
}

}

</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 me@mycompany.org.

Dec 1 '06 #1
1 1473
VK
<script language="javascript" >
>
function decideWhoToMailTo(dform) {
if (document.dform.ru.value == "122") {
document.dform.param_pie = "me@mycompany.org";
} else if (document.dform.ru.value == "144") {
document.dform.param_pie = "yo*@mycompany.org";
}

}

</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 = "m...@mycompany.org";
} else if (dform.ru.value == "144") {
dform.param_pie.value = "y...@mycompany.org";
}
}

</script>

Dec 1 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Sylvie Stone | last post by:
Hi group - I have an html form for that uses username and password to login to a specific area of the website. The "area" the user wants to go to is based on a pull down menu. Becasue the...
2
by: reneeccwest | last post by:
Different user input boxes are automatically populated based on a value of the dropdown box. Can anyone help me on that?
2
by: Irvin Amoraal | last post by:
I am new to javascript coding. I am using some javascript code to change an image on an html page. I would like the user to click on the image to bring them to another page. I need to change an...
4
by: Richard Cornford | last post by:
For the last couple of months I have been trying to get the next round of updates to the FAQ underway and been being thwarted by a heavy workload (the project I am working on has to be finished an...
1
by: SK | last post by:
Hi I am trying a simpler version of a program I was trying to write. The idea is to have someone enter the information and then at the end of the program display all of the info. in a table. I...
7
by: dotnetnoob | last post by:
i keep getting Object references not set to an instance of an object from this code: Private Sub EqBinding() Dim x As Integer x = 0 Do If CStr(arlsType.Item(x)) = "Bacnet Point" Then Dim...
2
by: Mirovk | last post by:
Hi, I have a session variable wich value arrives from a previous .asp but in my actual page I need to modify it based upon a selected value from a radio button. I will try to figure out for...
10
by: IchBin | last post by:
I am trying to set the state of a radio button. I do not see what I am doing wrong. Sorry, I am new at this.. I need another set of eyes to look at this snip of code. I am trying to set the radio...
11
by: cybervigilante | last post by:
I can't seem to change the include path on my local winmachine no matter what I do. It comes up as includ_path .;C:\php5\pear in phpinfo() but there is no such file. I installed the WAMP package...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.