...

View Full Version : Form output help



zoe09
03-15-2009, 01:18 AM
Can anyone tell me how to get the alert box to display in text instead. So when the user clicks on the submit button instead of an alert box, the result would display below the button in text instead of an alert? Any suggestions?
<script type = "text/javascript">

function validate (form){
var hrs=(form.hrs[0].checked)? form.hrs[0].value : form.hrs[1].value;

var flname = form.fullname.value;
flname = flname.replace(/[^a-zA-Z\s-/']/g,"");
if (flname.length < 5) {
alert ("Please re-enter your FULL NAME.");
return false;
}

var age = document.form1.yrs.value;
if (age == 0) { // nothing selected
alert ("Please select your age")
return false;
}

var calc=((hrs*form.yrs.value)/12).toFixed(2);
alert ("You spend " + calc +" years playing silly computer games")

alert("Thanks " + flname + " for completing the form correctly.");
return true; // return true is the default so this line is not required
}
</script>

</HEAD>
<BODY>
<FORM METHOD="post" name="form1" onSubmit="return validate(this)";
<!-- START HTML -->
<TABLE>
<TR>
<TH ALIGN="Left" COLSPAN="2"><H1> <U>HOURS SPENT PLAYING VIDEO GAMES</U></H1></TH>
</TR>
<TR>
<TD><B> FULL NAME: </B></TD>
<TD width="608"><INPUT NAME="fullname" TYPE="text"> (letters only) </TD>
</TR>
<TR>
<TD><B> HOURS A DAY: </B> </TD>
<TD><B><INPUT TYPE="radio" NAME="hrs" VALUE="2">2</B>
<B><INPUT TYPE="radio" NAME="hrs" VALUE="3" >3</B></TD>
</TR>
<TR>
<TD><B> how old are you?: </B></TD>
<TD><SELECT NAME="yrs">
<OPTION VALUE=""> How old are you </option>
<option value="01">1</option>
<option value="02">2</option>
</SELECT>
</TD>
</TR>
<!-- BUTTON -->
<tr>
<td colspan="2"><INPUT TYPE="submit" VALUE="SEND DATA"><INPUT TYPE="reset" VALUE="CLEAR FORM"></td>
</tr>
</TABLE>
</FORM>
</BODY>

TinyScript
03-15-2009, 01:31 AM
kinda like this I think

use innerHTML



<html xmlns="http://www.w3.org/1999/xhtml">
<head>

</head>

<body >


<script type = "text/javascript">
function doit(){
document.getElementById("someDiv").innerHTML="give it the html here"
}

</script>
<div ID="someDiv"></div>
<a href="#" onclick="doit()">do it</a>
</body>
</html>

zoe09
03-15-2009, 01:43 AM
okay i'll try it out, Thank You



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum