SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict buildakicker's Avatar
    Join Date
    Jun 2005
    Location
    NorCal
    Posts
    378
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Smile If Checked Populate with Same text

    Hi all,

    I am trying to determine if a checkbox is checked, and if so, grab text from one textarea and put it in the other text area below.

    I am not sure exactally how to do this. If I want it to load right when the check mark is checked do I have to use the AJAX function? I am thinking something like this, but am having trouble getting it to work:

    Code:
    var checkbox = document.getElementById("checkbox");
    var textarea = document.getElementById("textarea");
    
    if(!checkbox) return false;{
    }else{
    textarea = textarea 1's text...
    }
    SKILEASES.COM - FREE rental listings!
    WILDFIREBLOG.COM - Wildland Fire microblog!

  2. #2
    SitePoint Addict buildakicker's Avatar
    Join Date
    Jun 2005
    Location
    NorCal
    Posts
    378
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Maybe more like this:

    <script type="text/javascript">
    function fillAddress() {
    if (document.eventregform.event_at_this_address.checked) {
    document.eventregform.event_address = document.eventregform.getField('address').value;
    } else {
    return false;
    }
    }
    </script>
    SKILEASES.COM - FREE rental listings!
    WILDFIREBLOG.COM - Wildland Fire microblog!

  3. #3
    SitePoint Addict buildakicker's Avatar
    Join Date
    Jun 2005
    Location
    NorCal
    Posts
    378
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thumbs up Fill Textarea by using Checkbox

    Got it!

    Where event_at_this_address is your checkbox...
    eventregform is the name of the form...
    event_address is the name of the textarea to be filled....


    Code:
        <script type="text/javascript">
    		function fillAddress() {
    			if (document.eventregform.event_at_this_address.checked) {
    					document.eventregform.event_address.value = document.eventregform.address.value;
    				} else {
    					document.eventregform.event_address.value = "";
    				}
    		}
    	</script>
    SKILEASES.COM - FREE rental listings!
    WILDFIREBLOG.COM - Wildland Fire microblog!


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
  •