0

Hi there,
I am totally new to Java script (just began to looking into it) and I would like to do something with the comment box on one of the website I am working on http://antobbo.webspace.virginmedia.com/webediting/documents.htm
Basically rather than that box at the bottom of the page I was thinking to have a link saying something like "comment" and if I click on it the text box appears.
Now, this is my html comment box code:

<div class="comment_box">
<form action="mailto:myemail@domain.com" method="post">
<p>Comments and suggestions:<br><textarea name="comments" rows="3" cols="30"></textarea><br><br>
<input type="submit" value="Send"></p>
</form>
</div> <!-- end of comment_box-->

CSS

.comment_box

{
border-style:solid;
border-width:1px;
float:left;
background-color:#d4d4cb;
width:280px;
padding-left:20px;
padding-top:25px;
padding-bottom:10px;
}

and for the script I am not quite sure how to proceed. I suppose the box will need to be shown using a

document.write()

method but does it mean that I have to copy the content of my

<form></form>

into the script? So something like "if I click on the comment button show the box"?
this is what I came up so far, it is not much sorry

<script type="text/javascript">
<!--
function popup() {
	document.write() /* not quite sure what to put in it*/
}
//-->
</script>

<body>

</body>

<input type="button" value="Comment" onclick="popup()"><br />

ANy help/suggestion greatly appreciated
thanks

1
Contributor
1
Reply
5
Views
6 Years
Discussion Span
Last Post by Violet_82
0

this is roughly what I meant (I know the code is wrong because it doesn't work but still might clarify a bit )

<html>
<head>
<style type="text/css">
.comment_box

{
border-style:solid;
border-width:1px;
float:left;
background-color:#d4d4cb;
width:280px;
padding-left:20px;
padding-top:25px;
padding-bottom:10px;
}

</style>
<script type="text/javascript">
<!--
function popup(box) {

	comment= confirm("Do you want to leave a comment?")
	if(comment)
	{
	document.write("comment_box")
	}
	else
	{
	document.write("You cancelled")
	}
}
//-->
</script>
</head>
<body>




<input type="button" value="Comment" onclick="popup('comment_box')"><br />

<div class="comment_box">
<form action="mailto:myemail@domain.com" method="post">
<p>Comments and suggestions:<br><textarea name="comments" rows="3" cols="30"></textarea><br><br>
<input type="submit" value="Send"></p>
</form>

</div> <!-- end of comment_box-->

</body>
</html>

I don't really want the user to get a pop up confirmation window before he/she leaves a comment but the

confirm()

method was the only one I found that coould somehow help me

Edited by Violet_82: got the variables wrong!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.