Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Dec 2005
    Posts
    346
    Thanks
    1
    Thanked 0 Times in 0 Posts

    JavaScript help please

    I am not sure what this is called in Javascript is called so I just tell you my problem.

    I have a radio button that when I click on it it fills a 1 text box with data. This I have working just fine. I need the same click to fill a second text box with data. I will post my code below...currently it does fill the 1st text box without errors, but I need this to fill 2 text boxes & not just one.

    PHP Code:
    onClick="document.form_name.text_box1.value='<?=$name1 ?>';"
    Thanks!

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,910
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    onClick="document.form_name.text_box1.value='<?=$name1 ?>';document.form_name.text_box2.value='<?=$name1 ?>';"

  • #3
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    or if you need text_box3, tex_box4....

    onclick="var i=1;while(document.form_name['text_box'+i]){document.form_name['text_box'+i].value='<?=$name1 ?>';i++}"
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #4
    Regular Coder
    Join Date
    Dec 2005
    Posts
    346
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Philip M
    onClick="document.form_name.text_box1.value='<?=$name1 ?>';document.form_name.text_box2.value='<?=$name1 ?>';"
    I have this & it wont work. It wont populate anything in any text box. Will this coding work in all browsers?
    onClick="document.form_name.text_box1.value='<?=$name1 ?>'; document.form_name.text_box2.value='<?=$name2 ?>';"


    Quote Originally Posted by Kor
    or if you need text_box3, tex_box4....

    onclick="var i=1;while(document.form_name['text_box'+i]){document.form_name['text_box'+i].value='<?=$name1 ?>';i++}"
    Each text_box will have a different variable assigned to it. Like text_box1 will need $text_box1 & text_box2 will need $text_box2 variable.


  •  

    Posting Permissions

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