Results 1 to 6 of 6

Thread: undefined

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2002
    Posts
    87

    Unhappy undefined

    Code:
              <span lang="en-us"><font face="Tahoma" size="2">&nbsp;</font></span><font face="Tahoma"><input type="radio" value="Left" name="algin" checked><span lang="en-us"><font size="2">Left</font></span></font></p>
          <p>
              <font face="Tahoma"><span lang="en-us"><font size="2">&nbsp;</font></span><input type="radio" value="Right" name="algin"><span lang="en-us"><font size="2"> 
              Right</font></span></font></p>
          <p><input type="Button" onclick="alert(algin.value)" value="Submit" name="B1" size="20">
    Whay The Alert Is 'undefined' ?

  2. #2
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    Code:
    onclick="javascript:alert(algin.value)"
    edit: there's not supposed to be a space betweern java and script, vbforums does this
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Dec 2002
    Posts
    87
    No
    Doesn't this ..

  4. #4
    Frenzied Member Acidic's Avatar
    Join Date
    Sep 2003
    Location
    UK
    Posts
    1,090
    also it's document.whatever.value
    But even this moght not work depending on where in the DOM the element is located. give the element in id and the do document.getElementById(id).value

    eg:
    Code:
    <input type="radio" value="Right" name="algin" id="myID">
    <input type="Button" onclick="alert(document.getElementById('myID').value)" value="Submit" name="B1" size="20">
    Have I helped you? Please Rate my posts.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Dec 2002
    Posts
    87
    It's Always Show "Left"

    Code:
              <span lang="en-us"><font face="Tahoma" size="2">&nbsp;</font></span><font face="Tahoma"><input type="radio" value="Left" name="algin"  id="myID" checked><span lang="en-us"><font size="2">Left</font></span></font></p>
          <p>
              <font face="Tahoma"><span lang="en-us"><font size="2">&nbsp;</font></span><input type="radio" value="Right " name="algin" ><span lang="en-us"><font size="2"> 
              Right</font></span></font></p>
          <p><input type="Button" onclick="alert(document.getElementById('myID').value)"   value="Submit" name="B1" size="20">

  6. #6
    Frenzied Member Acidic's Avatar
    Join Date
    Sep 2003
    Location
    UK
    Posts
    1,090
    well, of course it will always show left. you've given the ID to the tag with value="Left". Note that no two elements can have the same ID attribute.
    Have I helped you? Please Rate my posts.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width