javascript - jquery to take in the typed text in a textarea and pass it to a backend handler (perl, php, etc..) -


i have simple 'textarea' in html:

<div id="textarea"> <textarea rows="20" cols="45" autofocus wrap> </textarea> </div> 

with 2 buttons:

<div class="buttonbox"> <a class="button" href="#"><span id="spbutton">solve problems</span></a> <a class="button" href="#"><span id="pmfbutton">pull finger</span></a> </div> 

i trying understand jquery allow button 'spbutton', when pressed following text entered 'textarea', captured , passed, in var backend, in case perl. have seen/tested xhr handler cases image transfer, , work fine, thought simple text far more... well... simple? not able grab typed text @ all, static text had placed within 'textarea' tags? missing something.

in following attempt, not able extract 'var' print text entered in alert:

$(function() { $('#spbutton').click(function() { var intext = $('textarea#textarea').val(); alert(intext); }); }); 

the above, while appearing syntactically(questionable) correct, not return typed text 'textarea' alert, bank alert popup 'undefined' text? have tried '.text()' grabs text encapsulated within 'textarea' tags. can @ have done far (very little) here: https://github.com/gmconklin/zephyr

apparently need rep post pics? hmm nonsensical, cannot provide screenshots due limitation, apologies.

thanks assistance.

-g

when write:

var intext = $('textarea#textarea').val(); 

that means textarea id textarea.

what want textarea inside div id textarea. this:

var intext = $('#textarea textarea').val(); 

Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -