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

Discussion in 'Javascript' started by TeknoShock, Dec 1, 2006.

  1. TeknoShock

    TeknoShock Guest

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

    }

    </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 .
    TeknoShock, Dec 1, 2006
    #1
    1. Advertising

  2. TeknoShock

    VK Guest

    > <script language="javascript" >
    >
    > function decideWhoToMailTo(dform) {
    > if (document.dform.ru.value == "122") {
    > document.dform.param_pie = "";
    > } else if (document.dform.ru.value == "144") {
    > document.dform.param_pie = "";
    > }
    >
    > }
    >
    > </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 = "";
    } else if (dform.ru.value == "144") {
    dform.param_pie.value = "";
    }
    }

    </script>
    VK, Dec 1, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. qwerty
    Replies:
    3
    Views:
    9,278
    Scott Allen
    Sep 30, 2004
  2. =?Utf-8?B?REo=?=
    Replies:
    2
    Views:
    468
    =?Utf-8?B?REo=?=
    Dec 1, 2005
  3. leon
    Replies:
    0
    Views:
    426
  4. Robert Cohen
    Replies:
    3
    Views:
    265
    Andrew Durstewitz
    Jul 15, 2003
  5. Replies:
    2
    Views:
    98
    sunilp
    Jan 5, 2006
Loading...

Share This Page