简体   繁体   中英

adding values entered by user in a separate text area

I need to display an HTML form where user enters a value in a field. A textarea is displayed in the same form. Once user inputs text into the text field and clicks on submit, the values submitted should be appended and displayed in the textarea box. Something like:

field 1: some text box

field 2: text box

Submit button

field 3: When i click submit, display the texts entered in field 1 and field 2 together in this textarea.

Any ideas on this will be very helpfull.

may be you want to do like this, try this one...

<input type="text" id="txt1"/>
<input type="text" id="txt2"/>
<input type="button" value="submit" id="btn1"/> 
<textarea id="txt3">hello</textarea>

$(document).ready(function(){
    $("#btn1").click(function(){
        txt1=$("#txt1").val();
        txt2=$("#txt2").val();
        //alert(txt1+txt2;
        $("#txt3").val(txt1+txt2);
    });
});

click on this for live demo: http://jsfiddle.net/vwckksL6/1/

thank you

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM