0

How can I load an article (textarea) dynamically writing in the input text field (article ID) ? I want to check the ID in my DB and load the articles associated to it. Can you people give me an example ?

2
  • all should be done without any button: no form/buttons Commented Aug 31, 2012 at 20:07
  • Try searching the interwebs for jQuery.ajax Commented Aug 31, 2012 at 20:08

2 Answers 2

1

Use ajax if possible.

<textarea id="id_name"></textarea>

<script>
jQuery(function(){
    jQuery.ajax({
        url: "content_page.jsp", // .php or whatever file you are using
        method: "GET",
        success: function(data){
            jQuery("textarea#id_name").val(data);
        }
    }); 
});

</script>
Sign up to request clarification or add additional context in comments.

2 Comments

@k.k what if the data displayed in the text area derives from a input text field ?
you need populate data into same page or from other page?
0

An improved Version

<textarea id="id_name"></textarea>

<script>
$(document).ready(function(){
    $.ajax({
        url: "content_page.php",
        method: "GET",
        success: function(data){
                 $("textarea#id_name").val(data);
         }
    }); 
});

</script>

More reading about this http://api.jquery.com/ready/

2 Comments

Really? I always thought that calling the jQuery object with a function was just an alias for $(document).ready.
@CallumMacrae My apologize !! I thought if the order is mixed we are in trouble!!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.