Click to See Complete Forum and Search --> : HTML form/ emailing


agthepeot
11-30-2002, 11:27 AM
Can any one get me the code to do the following?:

1. User clicks on a link/picture

2. Up pops a alert box (something they can't get out of without answering) that blocks them from getting back to the site they're on without answering.

3. In the box are 2 questions and a submit button.

4. They fill in the boxes and click submit.

5. If both boxes aren't filled, nothing happens (box stays there).

6. If both are, it emails the answers to a specified email and closes the box, allowing the user to continue doing whatever he/she was doing.

Is it possible?


best regards,
agthepoet

Rick Bull
12-01-2002, 06:26 AM
You can use confirm to ask a OK/Cancel question:


var returnValue = confirm('Click OK or Cancel');
alert(returnValue);


Not sure exactly what context you want it in. You can validate a form something like this:


<script type="text/javascript"><!--
function validateForm(formObject) {
if (formObject.name.value.length == 0 || formObject.email.value.length == 0) {
alert('Please fill in the required form elements');
return false;
} else
return true;
}
//--></script>
<form action="server_side_page.pl" onsubmit="return validateForm(this);"><p>
<input name="name" />
<input name="email" /><br />
<input type="submit" />
</p></form>


Note though that you should use your server side page (server_side_page.pl in this case) to recheck this, as not everyone has a JavaScript enabled browser.