View Full Version : Form output help

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

<FORM METHOD="post" name="form1" onSubmit="return validate(this)";
<!-- START HTML -->
<TD><B> FULL NAME: </B></TD>
<TD width="608"><INPUT NAME="fullname" TYPE="text"> (letters only) </TD>
<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>
<TD><B> how old are you?: </B></TD>
<OPTION VALUE=""> How old are you </option>
<option value="01">1</option>
<option value="02">2</option>
<!-- BUTTON -->
<td colspan="2"><INPUT TYPE="submit" VALUE="SEND DATA"><INPUT TYPE="reset" VALUE="CLEAR FORM"></td>

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

use innerHTML

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


<body >

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

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

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