HTML and Javascript ,?

tesfa k

New member
Im trying to create a form where people will be able to leave their details, comments + a rating. I've figured out how to show a summary for the comments but im stuck with the rating part. How do i go about in showing a summary for all this?



<html>

<head>
<title>Feedback Form</title>
<SCRIPT TYPE="text/javascript">
<!--


function showSummary(frm)
{
if (frm.Name.value == "" || frm.Email.value == "" || frm.Comments.value == "")
alert("Field is incomplet!")
else
alert("Name:"+frm.Name.value + "\nE-mail Address:"+frm.Email.value + "\nYour Message:"+frm.Comments.value)
frm.Name.value = ""
}


//-->
</SCRIPT>
</head>

<body bgcolor="white">
<h3><center>Feedback Form</center></h3>
<form name="form1" >

<fieldset><legend align="left">Please fill in your name and e-mail address below</legend>
</br>

Name:<input name="Name" type="text" size="20" Style="background:#E8E8E8"
tabindex="322" accesskey="n"/>
<br />

E-mail:<input name="Email" type="text" size="40" Style="background:#E8E8E8"
tabindex="3" accesskey="e"/>
</fieldset>
<br /></br></br>


<fieldset><legend align="left">Comments and Rating</legend>
</br>
Please enter your comments here:
</br>

<textarea cols="40" rows="10" name="Comments" STYLE="background:silver"
tabindex="1" accesskey="c">
</textarea>
</br></br></br>How useful did you find this website
</br><input type="radio" name="Rating" value="a"/>Very poor
</br><input type="radio" name="Rating" value="b"/>Not bad
</br><input type="radio" name="Rating" value="c"/>Good
</br><input type="radio" name="Rating" value="d"/>Awesome
</fieldset>

<input type="reset" value="Reset" accesskey="r"/>
<input type="submit" name="button" value="Submit" onClick="showSummary(this.form)"
accesskey="s"/>
</form>
</body>
</html>
 
<html>
<head>
<title>Feedback Form</title>
<SCRIPT TYPE="text/javascript">
<!--

function get_radiobtn(id)
{
var r = document.getElementsByName(id );
var cnt = -1;
for (i =0; i < r.length; i++) {
if (r.checked) {
cnt = i;
return r[cnt].value;
}
}
return "";
}

function showSummary(frm)
{
if (frm.Name.value == "" || frm.Email.value == "" || frm.Comments.value == "")
alert("Field is incomplete!")
else
var radio = get_radiobtn('Rating');
alert("Name:"+frm.Name.value + "\nE-mail Address:"+frm.Email.value + "\nYour Message:"+frm.Comments.value +"\nRating: " +radio);
frm.Name.value = ""
}


//-->
</SCRIPT>
</head>

<body bgcolor="white">
<h3><center>Feedback Form</center></h3>
<form name="form1" >

<fieldset><legend align="left">Please fill in your name and e-mail address below</legend>
</br>

Name:<input name="Name" type="text" size="20" Style="background:#E8E8E8"
tabindex="322" accesskey="n"/>



E-mail:<input name="Email" type="text" size="40" Style="background:#E8E8E8"
tabindex="3" accesskey="e"/>
</fieldset>

</br></br>


<fieldset><legend align="left">Comments and Rating</legend>
</br>
Please enter your comments here:
</br>

<textarea cols="40" rows="10" name="Comments" STYLE="background:silver"
tabindex="1" accesskey="c">
</textarea>
</br></br></br>How useful did you find this website
</br><input type="radio" name="Rating" value="a"/>Very poor
</br><input type="radio" name="Rating" value="b"/>Not bad
</br><input type="radio" name="Rating" value="c"/>Good
</br><input type="radio" name="Rating" value="d"/>Awesome
</fieldset>

<input type="reset" value="Reset" accesskey="r"/>
<input type="submit" name="button" value="Submit" onClick="showSummary(this.form)"
accesskey="s"/>
</form>
</body>
</html>
 
Back
Top