Getting The Value Of Textarea Inside Form December 25, 2023 Post a Comment I want to get the value of this textarea inside form and copy the the value to another textarea outside form using javascript. How should I do that? here's my textarea... Solution 1: There's no need for jQuery as some others have posted in their answer. Simply don't name your function the same thing you use for IDs and form names and it works:jsFiddle example<form> <textareaid="ttpName"name="ttpName"onchange="tpName(this)"style="margin-top: -9px; width: 275px; height: 40px;"></textarea> </form> <textareaid="copytpName"name="copytpName"style="margin-top: -9px; width: 275px; height: 40px;"></textarea>functiontpName(data) { document.getElementById("copytpName").value = data.value; } CopyI changed your textarea to <textarea id="ttpName" name="ttpName" ...Solution 2: You could do like this in javascript, HTML<form><textareaid="tpName"name="tpName"onkeyup="copyThis(this);"style="margin-top: -9px; width: 275px; height: 40px;"></textarea></form><textareaid="copytpName"name="copytpName"style="margin-top: -9px; width: 275px; height: 40px;"></textarea>CopyJAVASCRIPTfunctioncopyThis(txObj) { document.getElementById("copytpName").value = txObj.value; } CopyNote: You need to change the function name. The function name matches with the textarea name, so its creating the issue in your case.Baca JugaCss & Js Files Not Rendered When Deploy Of Asp.net Mvc Application On Iis 8 (windows 8)Catch Javascript Customevent By Jquery On() Preserving Custom Properties At First "level"Css Flexbox Display IssueTry this http://jsfiddle.net/CZCnx/2/Solution 3: I would try this:var text = document.getElementById("tpName").value; $("#copytpName").attr("value", text); CopySolution 4: I have added the code here, it uses jqueryhttp://jsfiddle.net/5B6KC/1/ CODE:$("#tpName").keyup(function(){ $("#copytpName").val($(this).val()); }) Copy Share You may like these postsSelect Marker Located Below A Rectangle Selection Drawn By User Over Google MapsFirebase Cloud Messaging Sendtodevice Works Properly But Sendmulticast Fails For The Same List Of TokensHow Can An Iframe That Has Content, Have An Undefined Contentdocument Object?Javascript Example Question: Lexical Scoping/closure - Eloquent Javascript Post a Comment for "Getting The Value Of Textarea Inside Form"
Post a Comment for "Getting The Value Of Textarea Inside Form"