Results 1 to 5 of 5

Thread: Javascript and HTML hidden fields

  1. #1

    Thread Starter
    Addicted Member HairyDave's Avatar
    Join Date
    Aug 2002
    Location
    Er...I can't remember.
    Posts
    196

    Javascript and HTML hidden fields

    OK, I have some hidden fields in my HTML document:

    <input type="hidden" name="myField" value="1"/>
    <input type="hidden" name="myField" value="2"/>
    <input type="hidden" name="myField" value="3"/>

    As you can see, they all have the same name, but different values. I am using servlets and JSP which allow you to use the request.getParameterValues("myField") methods, which return an array of strings.

    However, I want to access these from a javascript function. So how do I do this? I've tried:

    for(int i = 0; i < TheForm.myField.length; i++) document.write(TheForm.myField[i].value);

    but this doesn't work.

    Any ideas would be greatly appreciated.

    HD

  2. #2
    Frenzied Member DeadEyes's Avatar
    Join Date
    Jul 2002
    Posts
    1,196
    Drop the int in the for loop

  3. #3
    Frenzied Member DeadEyes's Avatar
    Join Date
    Jul 2002
    Posts
    1,196
    Also I assume that bit of code is in a function

  4. #4

    Thread Starter
    Addicted Member HairyDave's Avatar
    Join Date
    Aug 2002
    Location
    Er...I can't remember.
    Posts
    196
    Cheers for that, should have thought of it myself but I was too stupid to look!

    Thanks again.

    HD

  5. #5
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Make sure this works with Mozilla, I'm not sure if it does.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

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