setting getElementById().value equal to variable value

Discussion in 'Javascript' started by ll, Aug 21, 2008.

  1. ll

    ll Guest

    I'm working with the script below which works with FF but not with IE
    7. To clarify, the part of the code which isn't working in IE 7 is
    putting the value of variable y in the "totalString" input box and
    alert.
    Thanks for any help,
    Louis
    -------------------------------------------------
    <script type="text/javascript">
    function upperCase()
    {
    var x=document.getElementById("fname").value;
    document.getElementById("fname").value=x.toUpperCase();
    //var b="used cars";
    //alert(x);
    }
    function numFlag()
    {
    var y=document.getElementById("number").value;
    document.getElementById("totalString").value="hello"+y;
    alert(y);
    //document.write y;
    }
    </script>


    <form>
    Enter your name: <input type="text" id="fname"
    onBlur="upperCase()"><br />
    Enter your age: <input type="text" id="age" onBlur="alert(this.id)">
    <br><br>
    <select name="test" id="number" onChange="numFlag()" size="1">
    <option>1</option>
    <option>2</option>
    <option>3</option>
    </select> <!---->

    <br>
    <br><br>
    <input name="totalString" id="totalString"></form>
    ll, Aug 21, 2008
    #1
    1. Advertising

  2. ll

    ll Guest

    On Aug 21, 7:20 pm, "GArlington" <> wrote:
    > "ll" <> wrote in message
    >
    > news:...
    >
    > > I'm working with the script below which works with FF but not with IE
    > > 7. To clarify, the part of the code which isn't working in IE 7 is
    > > putting the value of variable y in the "totalString" input box and
    > > alert.
    > > Thanks for any help,
    > > Louis
    > > -------------------------------------------------
    > > <script type="text/javascript">
    > > function upperCase()
    > > {
    > > var x=document.getElementById("fname").value;
    > > document.getElementById("fname").value=x.toUpperCase();
    > > //var b="used cars";
    > > //alert(x);
    > > }
    > > function numFlag()
    > > {
    > > var y=document.getElementById("number").value;
    > > document.getElementById("totalString").value="hello"+y;
    > > alert(y);
    > > //document.write y;
    > > }
    > > </script>

    >
    > > <form>
    > > Enter your name: <input type="text" id="fname"
    > > onBlur="upperCase()"><br />
    > > Enter your age: <input type="text" id="age" onBlur="alert(this.id)">
    > > <br><br>
    > > <select name="test" id="number" onChange="numFlag()" size="1">
    > > <option>1</option>
    > > <option>2</option>
    > > <option>3</option>
    > > </select> <!---->

    >
    > You might want to give the options above separate values...
    > <option value ="1">1</option>
    >
    >
    >
    > > <br>
    > > <br><br>
    > > <input name="totalString" id="totalString"></form>

    >
    > ** Posted fromhttp://www.teranews.com**




    Works like a charm! Many thanks - is there an easy-to-reference
    javascript book or site which might be of help for someone who
    rarely uses it?


    Thanks
    ll, Aug 22, 2008
    #2
    1. Advertising

  3. ll

    GArlington Guest

    On Aug 22, 3:50 pm, ll <> wrote:
    > On Aug 21, 7:20 pm, "GArlington" <> wrote:
    >
    >
    >
    > > "ll" <> wrote in message

    >
    > >news:...

    >
    > > > I'm working with the script below which works with FF but not with IE
    > > > 7. To clarify, the part of the code which isn't working in IE 7 is
    > > > putting the value of variable y in the "totalString" input box and
    > > > alert.
    > > > Thanks for any help,
    > > > Louis
    > > > -------------------------------------------------
    > > > <script type="text/javascript">
    > > > function upperCase()
    > > > {
    > > > var x=document.getElementById("fname").value;
    > > > document.getElementById("fname").value=x.toUpperCase();
    > > > //var b="used cars";
    > > > //alert(x);
    > > > }
    > > > function numFlag()
    > > > {
    > > > var y=document.getElementById("number").value;
    > > > document.getElementById("totalString").value="hello"+y;
    > > > alert(y);
    > > > //document.write y;
    > > > }
    > > > </script>

    >
    > > > <form>
    > > > Enter your name: <input type="text" id="fname"
    > > > onBlur="upperCase()"><br />
    > > > Enter your age: <input type="text" id="age" onBlur="alert(this.id)">
    > > > <br><br>
    > > > <select name="test" id="number" onChange="numFlag()" size="1">
    > > > <option>1</option>
    > > > <option>2</option>
    > > > <option>3</option>
    > > > </select> <!---->

    >
    > > You might want to give the options above separate values...
    > > <option value ="1">1</option>

    >
    > > > <br>
    > > > <br><br>
    > > > <input name="totalString" id="totalString"></form>

    >
    > > ** Posted fromhttp://www.teranews.com**

    >
    > Works like a charm! Many thanks - is there an easy-to-reference
    > javascript book or site which might be of help for someone who
    > rarely uses it?
    >
    > Thanks


    http://www.w3schools.com/jsref/default.asp
    GArlington, Aug 22, 2008
    #3
    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.

Share This Page