SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2000
    Location
    Palo Alto, CA
    Posts
    87
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello,
    for example I have

    Code:
     
    <form name="formname">
    <INPUT TYPE="hidden" name="test" value="test1">
    <INPUT TYPE="hidden" name="two" value="test2">
    <INPUT TYPE="hidden" name="other" value="test3">
    <INPUT TYPE="hidden" name="other" value="test4">
    <INPUT TYPE="hidden" name="test" value="test5">
    </form>
    Now I have little JavaScript:

    Code:
     
    alert(document.formname.test[0].value);
    Which shows "test1", and works in NN and IE.

    Now I need to be able to get text by passing 'name'
    of the object, which works in IE like this:



    Code:
     
    alert(document.formaname[getFromText()][0].value);
    
    function getFromText() {
         return "test";
    }
    Now, how do I pass result from the function, to 'prefill'
    the required parameter (document.formname.<PARAM>[0].value), because example above not working in NN.
    Or let's say I need something similar for NN.
    Thank you very much, I really need it.
    John.

  2. #2
    JavaScript Guru (Big Ego) Arielladog's Avatar
    Join Date
    Jul 1999
    Location
    SC, USA
    Posts
    390
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey John,

    Instead of trying to alert() this:

    Code:
    alert(document.formname[getFromText()][0].value);
    Try using an eval() to evaluate it like this:

    Code:
    alert(eval("document.formname."+getFromText()+"[0].value"));
    Also, you had "formaname" instead of "formname"

    Good Luck,
    aDog


Bookmarks

Posting Permissions

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