SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict
    Join Date
    Apr 2004
    Location
    canada
    Posts
    274
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    jQuery - AutoFill Text Box

    I'm looking for a textbox Auto-fill script NOT an auto-complete script in jQuery.

    Here's is how it works:
    1) Radiobutton and textbox on the page
    2) Click the radio button
    3) Auto fill text box with radio button value

    Here is a version is just JS:

    Code:
    <script language="JavaScript" type="text/javascript">
    function autoFill(input,output){
     document.forms[0].elements[output].value=input.value;
    }
    </script>
    Here's the radio button onClick code:
    Code:
    <input type="radio" onclick="autoFill(this,'txtDoorStyle')" value="Door Half Transom (011)" name="doorstyle">
    And the text box that gets autofilled:
    Code:
    <input type="text" value="" id="txtDoorStyle" name="txtDoorStyle" >
    I need a jQuery version that can autofill multiple textboxes with the same radio button value.

    I have looked all over google and all I get are AUTO-COMPLETE textbox results.

    Anyone have any leads or ideas?

    THANKS!!!!

  2. #2
    SitePoint Enthusiast
    Join Date
    May 2003
    Location
    Nova Scotia, Canada
    Posts
    44
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here would be a jQuery version

    HTML Code:
    <html>
    <head>
    <title>Untitled Document</title>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
    <script type="text/javascript">
    $(function(){
    	$('#radioid').click(function() {
      		$('#txtDoorStyle').val($(this).val());
    	});
    });
    </script>
    </head>
    <body>
    <input type="radio" id="radioid" value="Door Half Transom (011)" name="doorstyle">
    <input type="text" value="" id="txtDoorStyle" name="txtDoorStyle" >
    </body>
    </html>

  3. #3
    SitePoint Addict
    Join Date
    Apr 2004
    Location
    canada
    Posts
    274
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Jeremy, this is perfect. Thanks for your help and time!!!

  4. #4
    SitePoint Enthusiast
    Join Date
    May 2003
    Location
    Nova Scotia, Canada
    Posts
    44
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No problem, glad to help!


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
  •