Results 1 to 2 of 2

Thread: Text field names and updates

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2001
    Location
    Denmark
    Posts
    1,049

    Question Text field names and updates

    I have three text fields with the names
    Code:
    <input type=text name=t1 onclick="test();">
    <input type=text name=t2>
    <input type=text name=t3>
    when I click the first field I wish to set the value of all the three text fields with a function. I have tried the code below, but I can't make it work? Any ideas?
    Code:
    function test1(){
    for (i=1;i<4; i++){
    	document.formName.t + i + .value=25;
    }

  2. #2
    Fanatic Member punkpie_uk's Avatar
    Join Date
    Sep 2001
    Location
    UK
    Posts
    645
    this should do it...

    Code:
    <html>
    <head>
    <title>Untitled</title>
    <script language="JavaScript" type="text/javascript">
    <!--
    function test1(){
      for (i=1;i<4;i++){
      	document.forms('form1').elements('t'+i).value=25;
      }
    }
    //-->
    </script>
    
    </head>
    <body>
    <form name="form1">
      <input type=text name=t1 onclick="test1();">
      <input type=text name=t2>
      <input type=text name=t3>
    </form>
    </body>
    </html>
    SPREAD THE WORD!!! Are You Lee McCormick? Because I Am



    Lee M McCormick
    [email protected]

    Lee McCormick.com - Live
    Dynamically Webbed.com - In development but live

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