I am not skilled with coding script more a designer and I am using a very old java script that I know how to use as it quite basic.
What I need to do is to find a way to add certain function to work in my form.
Firstly, I want to find a way SO the form can only be submitted if a option value is selected in the LIST/MENU name="title", otherwise the pop up appears with a error warning (please select an option). I am using the javascript below for the pop up.
The pop up message is working on text fields but need help with the LIST/Menu TO WORK AS WELL?
This is an example of the LIST/MENU name="title"
<BODY>
<select name="title" size="1" id="title" onfocus = "getValue(this)" onblur = "setValue(this)">
<option>Please Select</option>
<option value="Mr">Mr</option>
<option value="Mrs">Mrs</option>
<option value="Ms">Ms</option>
<option value="Miss">Miss</option>
<option value="Dr">Dr</option>
</select>
</BODY
THIS IS THE JAVA SCRIPT POP UP IM USING IN THE HTML PAGE
</HEAD>
<script language="JavaScript" type="text/javascript">
<!-- Begin
function Start(page) {OpenWin = this.open(page, "CtrlWindow", "toolbar=no,menubar=no,location=no,scrollbars=no,re size=no,height=500,width=600");}
// End -->
</script>
<BODY>
THIS IS THE JAVASCRIPT I'M USING IN THE HTML PAGE
<HEAD>
<!-- Begin
function getCookie(name){
var cname = name + "=";
var dc = document.cookie;
if (dc.length > 0) {
begin = dc.indexOf(cname);
if (begin != -1) {
begin += cname.length;
end = dc.indexOf(";", begin);
if (end == -1) end = dc.length;
return unescape(dc.substring(begin, end));
}
}
return null;
}
function setCookie(name, value) {
var now = new Date();
var then = new Date(now.getTime() + 31536000000);
document.cookie = name + "=" + escape(value) + "; expires=" + then.toGMTString() + "; path=/";
}
function getInfo(form) {
form.info.value = "Browser Information: " + navigator.userAgent;
}
function getValue(element) {
var value = getCookie(element.name);
if (value != null) element.value = value;
}
function setValue(element) {
setCookie(element.name, element.value);
}
function fixElement(element, message) {
alert(message);
element.focus();
}
function isMailReady(form) {
var passed = false;
if (form.title.value == "") {
fixElement(form.title, "Please include your title.");
}
else if (form.fullname.value == "") {
fixElement(form.fullname, "Please include your full name.");
}
else {
getInfo(form);
passed = true;
}
return passed;
}
// End -->
</script>
<base target="_self" />
<script type="text/javascript">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->
</script>
</HEAD>
THIS IS THE <FORM> IN THE HTML PAGE
<BODY>
<form method="post" action="thanks.asp" onsubmit = "return isMailReady(this);">
<td>
<div align="left">
<select name="title" size="1" id="title" onfocus = "getValue(this)" onblur = "setValue(this)">
<option>Please Select</option>
<option value="Mr">Mr</option>
<option value="Mrs">Mrs</option>
<option value="Ms">Ms</option>
<option value="Miss">Miss</option>
<option value="Dr">Dr</option>
</select>
</div>
</td>
<td>
<div align="left">
<input type="text" name="fullname" size="40" onfocus = "getValue(this)" onblur = "setValue(this)" />
</div>
</td>
</BODY>
THIS IS THE POSTING ASP CODE - PAGE EXTENSION .ASP
<%'BEGIN Send email
set contactemail = server.createobject("cdonts.newmail")
contactemail.to="webmaster@test.com"
contactemail.from="myemail@test.com" & "<" 'myemail@test.com' & ">"
contactemail.subject="MESSAGE" & custid
contactemail.body="MESSAGE" & chr(13) & chr(13) & chr(13) & chr(13) & chr(13) & "Title: " & request.form("title") & chr(13) & "Full Name: " & request.form("fullname") & chr(13)
contactemail.Send()
'END Send email%>
<%'BEGIN Send email
set contactemail = server.createobject("cdonts.newmail")
contactemail.to=request.form("email")
contactemail.from="myemail@test.com" & "<" 'myemail@test.com' & ">"
contactemail.subject="MESSAGE" & custid
contactemail.body="MESSAGE" & chr(13) & chr(13) & chr(13) & chr(13) & chr(13) & "Title: " & request.form("title") & chr(13) & "Full Name: " & request.form("fullname") & chr(13)
contactemail.Send()
'END Send email%>
<html>
<head>
<title></title>
The pop up message is working on text fields request.form("fullname") but need help with the LIST/Menu request.form("title")?
I know its just a simple change somewhere here I think?
if (form.title.value == "") {
fixElement(form.title, "Please include your title.");
But if anyone can show me how I would be really grateful
Thanks
Gary


