php - jQuery - Display a textbox when a link/button is clicked -


i'm trying put reply button each comment when click on button (for example "reply"), textbox come automatically users can fill in form.

i didn't far...

php

<div id='replycomment' class='reply' onclick='jsreply($comment_id);'>reply</div> <div id='showreply'></div> 

jquery

function jsreply(comment_id) {     var form = '<form id="showreplyform" action"add_reply.php" method="post">';     form += '<textarea name="replybody" cols="35" rows="2" maxlength="299"</textarea>';     form += '<input type="hidden" name="replybodyid" value="' + comment_id + '" />'     form += '<input type="submit" name="replysubmit" value="reply"/></form>';     jquery('#replybody').replacewith(form); } 

can please me that? appreciated. i'm bit confused way need link id jquery php...

thank you

to make code work, this: http://jsfiddle.net/maqlq/1/

within head:

var jsreply = function(comment_id) {     var form = '<form id="showreplyform" action"add_reply.php" method="post">';     form += '<textarea name="replybody" cols="35" rows="2" maxlength="299"></textarea>';     form += '<input type="hidden" name="replybodyid" value="' + comment_id + '" />';     form += '<input type="submit" name="replysubmit" value="reply"/></form>';     jquery('#showreply').replacewith(form); } 

you missing semi-colin @ end of 1 of form concatenations. looking @ 'replybody' rather 'showreply' exists in html, , if code wasn't global html wouldn't have been defined onclick. missing end angle bracket opening textarea tag.

also, don't know context , i'm not here code review, among few other things... should avoid using onclick within html elements.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -