How would I create a text box in jquery that would appear when a certain button is clicked? Currently I have code that allows me to click a button and it shows an image and comments from a database. What I want it to do is also so a comment box so you can add more comments to each image.
<!DOCTYPE html>
<html>
<head>
<cfquery datasource=AccessTest name=qTest>
SELECT P.Account, P.Image, P.Image_ID, C.Remarks, C.Users, C.Accounts, C.Date_Time
FROM PictureDB AS P
INNER JOIN CommentsDB AS C
ON C.Image_ID = P.Image_ID
ORDER BY P.Image_ID
</cfquery>
<script src=http://code.jquery.com/jquery-2.0.3.js>
</script>
<script>
$(document).ready(function(){
var images = {
<cfoutput query=qTest group=Image_ID>
#qTest.Image_ID#: {
image: #qTest.Image#,
remarks: [
<cfoutput>
#qTest.Users#, #qTest.Date_Time# <br> #qTest.Remarks# <br> </br>,
</cfoutput>
]
},
</cfoutput>
};
$(button).click(function(event){
event.preventDefault();
var id = $(this).data(id);
var src = images[id].image;
var desc = images[id].remarks.toString();
$(#theImage).attr(src, src).removeClass(hide);
$(#theDescription).html(desc).removeClass(hide);
});
});
</script>
</head>
<body>
<cflayout name=myAccordionLayout type=accordion width=600px>
<cflayoutarea title=Bill Analysis align=left>
<cfoutput query=qTest group=Account>
<button data-id=#qTest.Image_ID#>
#qTest.Account#
</button>
</cfoutput>
</cflayoutarea>
</cflayout>
<img id=theImage class=hide>
<div id=theDescription class=hide>
</div>
</body>
</html>
Then currently I am trying to work this code into the above code.
<html>
<script src=http://code.jquery.com/jquery-2.0.3.js>
</script>
<script>
$(document).ready(function(){
$(#addcomment).click(function ()
<!--- $(#postComment).show(slow);--->
});
});
</script>
<cfform name=InsertComments id=InsertComments>
<fieldset>
<div id=container>
<div id=mainContent>
<div id=addcomment> <a href='#'>add comment</a></div>
<div id='postComment'>
<cftextarea name=Remarks cols=55 rows=4 label=Tour Description
required=yes validateat=OnSubmit message=Please enter your comment here
enabled=no>
</cftextarea>
<cfinput type=text name=Image_ID message=Please enter Account Here.
validateat=onSubmit required=yes id=Image_ID size=10
maxlength=60>
</cfinput>
<cfinput type=submit name=insertComments value=Insert Comments id=submit>
</cfinput>
</div>
</div>
</fieldset>
</cfform>
<cfif IsDefined(form.InsertComments)>
<cfquery datasource=AccessTest>
INSERT INTO CommentsDB (Remarks, Image_ID, Date_Time )
VALUES
(<cfqueryparam value=#form.Remarks# cfsqltype=CF_SQL_LONGVARCHAR>
</cfqueryparam>
, <cfqueryparam value=#form.Image_ID# cfsqltype=cf_sql_integer>
</cfqueryparam>
, <cfqueryparam value=#now()# cfsqltype=cf_sql_timestamp>
</cfqueryparam>
)
</cfquery>
</cfif>
</div>
</html>