Results 1 to 5 of 5

Thread: JavaScript

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2000
    Location
    Manchester NH
    Posts
    833
    I have this
    ------------------------------------------

    <form name = "Myform">
    <select name = "S[1]">
    <option value="1">orange
    <option value="2">red
    </select>
    </form>

    ---------------------------------------
    I am using the S[1] because I am passing it off to a PHP script than handles all the "S" selects as an array
    ---------------------------------------
    how can I use javascript to check to value of the select

    <Script= "JavaScript">
    alert(document.Myform.S[1].value)
    </script>

    doesn't work
    "document.Myform.S.1 is not an object"
    Kurt Simons
    [I know I'm a hack but my clients don't!]

  2. #2
    kayoca
    Guest
    Perhaps this will give you an idea how to handle JavaScript objects.
    Code:
    <html>
    <head>
    <title></title>
    
    <script language=javascript>
    <!--
    
    function button_onclick() {
      alert( document.myform.s.value )
    }
    
    //-->
    </script>
    
    </head>
    <body>
    
    <form name="myform">
      <select name="s"> 
        <option value="1">orange
        <option value="2">red
      </select>
      <input type="button" value="button" id="button" name="button"  language=javascript onclick="return button_onclick()">
    </form>
    
    </body>
    </html>

  3. #3
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845
    all objects are arrays in html

    Code:
    <html>
    <Script language="JavaScript">
    function x(){ 
    alert(document.Myform.S[1].value) 
    }
    </script> 
    
    <body>
    
    <form name = "Myform"> 
    <select name = "S"> <!-- this select is S[0] -->
    <option value="1">orange 
    <option value="2">red 
    </select> 
    
    <select name = "S"> <!-- this select is S[1] -->
    <option value="1">green 
    <option value="2">purple
    </select> 
    <input type='button' onclick='x()'
    </form> 
    
    </body>
    </html>
    Mark
    -------------------

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2000
    Location
    Manchester NH
    Posts
    833
    thanks,

    I get it but its going to give me a couple of problems.
    But I think I will be able to work around it by making my code nice and messy


    I need to assign the array values my self
    it might not be 0,1,2,3

    but it needs to be

    445,743,162

    but again I can work around this by adding a hidden field that holds the real values for the arrays, so when it is passed off to the script the script knows whats up

    S[0]=s[445]
    etc
    Kurt Simons
    [I know I'm a hack but my clients don't!]

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2000
    Location
    Manchester NH
    Posts
    833
    Can't get it to work

    how do I read the selects in my PHP script

    echo S[0];
    echo S[1];

    I am only receiving the last one
    Kurt Simons
    [I know I'm a hack but my clients don't!]

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