Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Change value of one variable based on user input of another value

Reply
Thread Tools

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

 
 
TeknoShock
Guest
Posts: n/a
 
      12-01-2006
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 Removed)";
} else if (document.dform.ru.value == "144") {
document.dform.param_pie = "(E-Mail 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 http://www.velocityreviews.com/forums/(E-Mail Removed).

 
Reply With Quote
 
 
 
 
VK
Guest
Posts: n/a
 
      12-01-2006
> <script language="javascript" >
>
> function decideWhoToMailTo(dform) {
> if (document.dform.ru.value == "122") {
> document.dform.param_pie = "(E-Mail Removed)";
> } else if (document.dform.ru.value == "144") {
> document.dform.param_pie = "(E-Mail 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 Removed)";
} else if (dform.ru.value == "144") {
dform.param_pie.value = "(E-Mail Removed)";
}
}

</script>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating a form that will change the number of fields based on user input ghadley_00@yahoo.com Javascript 2 01-05-2006 06:18 AM
Change web controls in one user control from another user control =?Utf-8?B?REo=?= ASP .Net 2 12-01-2005 08:26 AM
restrict the value of one child based on value from another child leon XML 0 09-27-2005 03:32 PM
How to access: a page from a User control, and another User controlfrom another one? qwerty ASP .Net 3 09-30-2004 05:32 PM
Passing value from one script on one page to another script on another page. Robert Cohen ASP General 3 07-15-2003 01:46 PM



Advertisments