Accessing a field variable with spaces in it.. HELPPPPPPPPP !!!!

Discussion in 'Javascript' started by Pooj, Aug 12, 2004.

  1. Pooj

    Pooj Guest

    I have a form having field as below :

    <input type="text" maxlength="12" id="attributes1" name="Alert Code"
    value="001" onChange="convert(this)">

    I want to alert the value inputted by the user in this field. The form
    name is MainForm. I used :

    alert(document.MainForm["0_Alert Code"].value)

    But it is giving some wiered numbers like 91807168

    What does this mean How Can i alert the value entered ?

    Please help this is very urgent !!!
     
    Pooj, Aug 12, 2004
    #1
    1. Advertising

  2. Pooj

    Hywel Guest

    In article <>, Pooj
    says...
    > I have a form having field as below :
    >
    > <input type="text" maxlength="12" id="attributes1" name="Alert Code"
    > value="001" onChange="convert(this)">
    >
    > I want to alert the value inputted by the user in this field. The form
    > name is MainForm. I used :
    >
    > alert(document.MainForm["0_Alert Code"].value)


    What's the "O_" for in that?

    --
    Hywel

    http://sponsorhywel.org.uk/
     
    Hywel, Aug 12, 2004
    #2
    1. Advertising

  3. Pooj

    Randy Webb Guest

    Pooj wrote:
    > I have a form having field as below :
    >
    > <input type="text" maxlength="12" id="attributes1" name="Alert Code"
    > value="001" onChange="convert(this)">




    > I want to alert the value inputted by the user in this field. The form
    > name is MainForm. I used :


    Since you are passing a reference to the convert function, you can
    simply use that reference:

    function convert(fieldRef){
    alert(fieldRef.value)
    }

    > alert(document.MainForm["0_Alert Code"].value)
    >
    > But it is giving some wiered numbers like 91807168


    since you use 0_Alert Code in the script but Alert Code in the HTML, its
    totally surprising you got the alert at all.

    > What does this mean How Can i alert the value entered ?
    >
    > Please help this is very urgent !!!


    Everything is "urgent" until you are dead, then it doesn't matter anymore.

    --
    Randy
    comp.lang.javascript FAQ - http://jibbering.com/faq
     
    Randy Webb, Aug 12, 2004
    #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.
Similar Threads
  1. John B. Matthews
    Replies:
    4
    Views:
    697
    John B. Matthews
    Sep 12, 2008
  2. Roedy Green
    Replies:
    3
    Views:
    658
  3. Tomasz Chmielewski

    [CSS] how can I show spaces as spaces?

    Tomasz Chmielewski, Sep 5, 2009, in forum: HTML
    Replies:
    21
    Views:
    1,683
    Jan C. Faerber
    Sep 10, 2009
  4. Tomasz Chmielewski

    how can I show spaces as spaces, part 2

    Tomasz Chmielewski, Sep 9, 2009, in forum: HTML
    Replies:
    14
    Views:
    910
    Jan C. Faerber
    Sep 10, 2009
  5. johkar
    Replies:
    2
    Views:
    3,047
    Mayeul
    Dec 10, 2009
Loading...

Share This Page