Someone please fix this code?

R

rked

I get nameSPAN1 is undefined when I place cursor in comments box..

<%@ LANGUAGE="VBScript" %>
<% DIM ipAddress
ipAddress=Request.Servervariables("REMOTE_HOST")
%>
<html>

<head>
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<script>
<!--
function submit_rcd()
{
document.form1.action = "webmail_send.asp";
document.form1.submit();
}
function cancel_cmd()
{ window.close()
}


function validField() // !!!THIS IS WHERE PROBLEM EXISTS!!!!
{
if (document.formDoubleMenuDMA.strSubject.value == "")
{ nameSPAN1.innerHTML = "Please select a subject";
nameSPAN1.style.color='#FF0000';
alert("Please Enter A Subject");
return false; }
else
{ nameSPAN1.innerHTML = "";
return true; }
}



function validField2()
{ nameSPAN2.innerHTML = "Please type a valid email<br>";
nameSPAN2.style.color='#FF0000';
}


function validField3()
{ nameSPAN2.innerHTML = "Valid Email! Thankyou for your
cooperation!<br>";
nameSPAN2.style.color='#00CD66';
}


function checkEmail(strFromAddress){ //reference to email field passed
as argument

var fieldValue = strFromAddress.value // store field's entire value in
variable

// Begin Valid Email Address Tests

//if field is not empty
if(fieldValue != ""){
var atSymbol = 0

//loop through field value string
for(var a = 0; a < fieldValue.length; a++){

//look for @ symbol and for each @ found, increment atSymbol variable
by 1
if(fieldValue.charAt(a) == "@"){
atSymbol++
}

}

// if more than 1 @ symbol exists
if(atSymbol > 1){
// then cancel and don't submit form
alert("Please Enter A Valid Email Address")
validField2()
return false
}

// if 1 @ symbol was found, and it is not the 1st character in string
if(atSymbol == 1 && fieldValue.charAt(0) != "@"){
//look for period at 2nd character after @ symbol
var period = fieldValue.indexOf(".",fieldValue.indexOf("@")+2)

// "." immediately following 1st "." ?
var twoPeriods = (fieldValue.charAt((period+1)) == ".") ? true : false

//if period was not found OR 2 periods together OR field contains less
than 5 characters OR period is in last position
if(period == -1 || twoPeriods || fieldValue.length < period + 2 ||
fieldValue.charAt(fieldValue.length-1)=="."){
// then cancel and don't submit form
alert("Please Enter A Valid Email Address")
validField2()
return false
}

}
// no @ symbol exists or it is in position 0 (the first character of
the field)
else{
// then cancel and don't submit form
alert("Please Enter A Valid Email Address")
validField2()
return false
}
}
// if field is empty
else{
// then cancel and don't submit form
alert("Please Enter A Valid Email Address")
validField2()
return false
}

//all tests passed, submit form
//alert("VALID EMAIL ADDRESS!")
validField3()
return true
}

//-->
//-->
</script>
<title>Email Departments</title>
<script language="javascript">

<!--//

//new Option("text","value")

//this code changes menus







function nullOptionsDMA(aMenu){

var tot=aMenu.options.length

for (i=0;i<tot;i++)

{

aMenu.options=null

}

aMenu.options.length=0;

}



function MySubjectDMA0(aMenu){

nullOptionsDMA(aMenu)



with (aMenu){



//Rewrites the text and values

options[0]=new Option("Select a subject","");

options[1]=new Option("Addressing","Addressing");

options[2]=new Option("Questions","Questions");

options[3]=new Option("Complaints","Complaints");

options[4]=new Option("Comments","Comments");

options[5]=new Option("Suggestions","Suggestions");

options[0].selected=true





}

}

function MySubjectDMA1(aMenu){

nullOptionsDMA(aMenu)



with (aMenu){



//Rewrites the text and values

options[0]=new Option("Select a subject","none");

options[1]=new Option("Adoptions","Adoptions");

options[2]=new Option("Lost Pets","Lost Pets");

options[3]=new Option("Found Pets","Found Pets");

options[4]=new Option("Licensing","Licensing");

options[5]=new Option("Neuter Commuter","Neuter Commuter");

options[6]=new Option("Microchips","Microchips");

options[7]=new Option("Address Updates","Address Updates");

options[8]=new Option("Volunteer Info","Volunteer Info");

options[9]=new Option("Foster Info","Foster Info");

options[9]=new Option("Community Service Info","Community Service
Info");

options[10]=new Option("General","General");

options[0].selected=true





}

}

function MySubjectDMA2(aMenu){

nullOptionsDMA(aMenu)



with (aMenu){



//Rewrites the text and values

options[0]=new Option("Select a subject","none");

options[1]=new Option("Contractor Complaints","Contractor Complaints");

options[2]=new Option("Non-Permit Work","Non-Permit Work");

options[3]=new Option("Complaint about Inspecation Result","Complaint
about Inspecation Result");

options[4]=new Option("Information about Permitting Process
","Information about Permitting Process");

options[5]=new Option("Permit Status Request","Permit Status Request");

options[6]=new Option("Permit Form Request","Permit Form Request");

options[7]=new Option("Non-Permit Work","Non-Permit Work");

options[8]=new Option("Can I build on my property?","Can I build on my
property?");

options[9]=new Option("Request for Contractor Newsletter via Email
","Request for Contractor Newsletter via Email");

options[10]=new Option("General");

options[0].selected=true





}

}

function MySubjectDMA3(aMenu){

nullOptionsDMA(aMenu)



with (aMenu){



//Rewrites the text and values

options[0]=new Option("Select a page","none");

options[1]=new Option("Animal Control","Animal Control");

options[2]=new Option("Animal Cruelty","Animal Cruelty");

options[3]=new Option("Littering","Littering");

options[4]=new Option("Junk and Unserviceable Vehicles","Junk and
Unserviceable Vehicles");

options[5]=new Option("Noise","Noise");

options[6]=new Option("Zoning Issues","Zoning Issues");

options[7]=new Option("General");


options[0].selected=true





}

}

function MySubjectDMA4(aMenu){

nullOptionsDMA(aMenu)



with (aMenu){



//Rewrites the text and values

options[0]=new Option("Select a page","none");

options[1]=new Option("CDBG Inquiries","CDBG Inquiries");

options[2]=new Option("Ship Program","Ship Program");

options[3]=new Option("Housing Assistance","Housing Assistance");

options[4]=new Option("Housing Loans","Housing Loans");

options[5]=new Option("General");

options[0].selected=true





}

}


function MySubjectDMA5(aMenu){

nullOptionsDMA(aMenu)



with (aMenu){



//Rewrites the text and values

options[0]=new Option("Select a page","none");

options[1]=new Option("Questions","Questions");

options[2]=new Option("Complaints","Complaints");

options[3]=new Option("Comments","Comments");

options[4]=new Option("Suggestions","Suggestions");


options[0].selected=true





}

}

function MySubjectDMA6(aMenu){

nullOptionsDMA(aMenu)



with (aMenu){



//Rewrites the text and values

options[0]=new Option("Select a page","none");

options[1]=new Option("Questions","Questions");

options[2]=new Option("Complaints","Complaints");

options[3]=new Option("Comments","Comments");

options[4]=new Option("Suggestions","Suggestions");


options[0].selected=true





}

}

function MySubjectDMA7(aMenu){

nullOptionsDMA(aMenu)



with (aMenu){



//Rewrites the text and values

options[0]=new Option("Select a page","none");

options[1]=new Option("Questions","Questions");

options[2]=new Option("Complaints","Complaints");

options[3]=new Option("Comments","Comments");

options[4]=new Option("Suggestions","Suggestions");


options[0].selected=true





}

}

function MySubjectDMA8(aMenu){

nullOptionsDMA(aMenu)



with (aMenu){



//Rewrites the text and values

options[0]=new Option("Select a page","none");

options[1]=new Option("Questions","Questions");

options[2]=new Option("Complaints","Complaints");

options[3]=new Option("Comments","Comments");

options[4]=new Option("Suggestions","Suggestions");


options[0].selected=true





}

}

function MySubjectDMA9(aMenu){

nullOptionsDMA(aMenu)



with (aMenu){



//Rewrites the text and values

options[0]=new Option("Select a page","none");

options[1]=new Option("Questions","Questions");

options[2]=new Option("Complaints","Complaints");

options[3]=new Option("Comments","Comments");

options[4]=new Option("Suggestions","Suggestions");


options[0].selected=true





}

}

function MySubjectDMA10(aMenu){

nullOptionsDMA(aMenu)



with (aMenu){



//Rewrites the text and values

options[0]=new Option("Select a page","none");

options[1]=new Option("Park Fees","Park Fees");

options[2]=new Option("Park Inquiry","Park Inquiry");

options[3]=new Option("General");


options[0].selected=true





}

}

function MySubjectDMA11(aMenu){

nullOptionsDMA(aMenu)



with (aMenu){



//Rewrites the text and values

options[0]=new Option("Select a page","none");

options[1]=new Option("Planning Inquiries","Planning Inquiries");

options[2]=new Option("Transportation Inquiries","Transportation
Inquiries");

options[3]=new Option("Transportation Impact Fees","Transportation
Impact Fees");

options[4]=new Option("Fire Impact Fees","Fire Impact Fees");

options[5]=new Option("Property Access-Easements","Property
Access-Easements");

options[6]=new Option("Surplus Land Sales","Surplus Land Sales");

options[7]=new Option("Plat Vacations","Plat Vacations");

options[8]=new Option("Road Closings","Road Closings");

options[9]=new Option("Scenic Roads","Scenic Roads");

options[10]=new Option("General");

options[0].selected=true





}

}

function MySubjectDMA12(aMenu){

nullOptionsDMA(aMenu)



with (aMenu){



//Rewrites the text and values

options[0]=new Option("Select a page","none");

options[1]=new Option("Questions","Questions");

options[2]=new Option("Complaints","Complaints");

options[3]=new Option("Comments","Comments");

options[4]=new Option("Suggestions","Suggestions");


options[0].selected=true





}

}

function MySubjectDMA13(aMenu){

nullOptionsDMA(aMenu)



with (aMenu){



//Rewrites the text and values

options[0]=new Option("Select a page","none");

options[1]=new Option("Right of Way Permits","Right of Way Permits");

options[3]=new Option("General");

options[0].selected=true





}

}

function MySubjectDMA14(aMenu){

nullOptionsDMA(aMenu)



with (aMenu){



//Rewrites the text and values

options[0]=new Option("Select a page","none");

options[1]=new Option("Questions","Questions");

options[2]=new Option("Complaints","Complaints");

options[3]=new Option("Comments","Comments");

options[4]=new Option("Suggestions","Suggestions");


options[0].selected=true





}

}

function MySubjectDMA15(aMenu){

nullOptionsDMA(aMenu)



with (aMenu){



//Rewrites the text and values

options[0]=new Option("Select a page","none");

options[1]=new Option("Questions","Questions");

options[2]=new Option("Complaints","Complaints");

options[3]=new Option("Comments","Comments");

options[4]=new Option("Suggestions","Suggestions");


options[0].selected=true





}

}

function MySubjectDMA16(aMenu){

nullOptionsDMA(aMenu)



with (aMenu){



//Rewrites the text and values

options[0]=new Option("Select a page","none");

options[1]=new Option("Questions","Questions");

options[2]=new Option("Complaints","Complaints");

options[3]=new Option("Comments","Comments");

options[4]=new Option("Suggestions","Suggestions");


options[0].selected=true





}

}
function MySubjectDMA16(aMenu){

nullOptionsDMA(aMenu)



with (aMenu){



//Rewrites the text and values

options[0]=new Option("Select a page","none");

options[1]=new Option("Roadway Project Inquiries","Roadway Project
Inquiries");

options[2]=new Option("Speed Limit Inquiries","Speed Limit Inquiries");

options[3]=new Option("General");


options[0].selected=true





}

}
function MySubjectDMA17(aMenu){

nullOptionsDMA(aMenu)



with (aMenu){



//Rewrites the text and values

options[0]=new Option("Select a page","none");

options[1]=new Option("Questions","Questions");

options[2]=new Option("Complaints","Complaints");

options[3]=new Option("Comments","Comments");

options[4]=new Option("Suggestions","Suggestions");


options[0].selected=true





}

}
function MySubjectDMA18(aMenu){

nullOptionsDMA(aMenu)



with (aMenu){



//Rewrites the text and values

options[0]=new Option("Select a page","none");

options[1]=new Option("Questions","Questions");

options[2]=new Option("Complaints","Complaints");

options[3]=new Option("Comments","Comments");

options[4]=new Option("Suggestions","Suggestions");


options[0].selected=true





}

}
function MySubjectDMA19(aMenu){

nullOptionsDMA(aMenu)



with (aMenu){



//Rewrites the text and values

options[0]=new Option("Select a page","none");

options[1]=new Option("Questions","Questions");

options[2]=new Option("Complaints","Complaints");

options[3]=new Option("Comments","Comments");

options[4]=new Option("Suggestions","Suggestions");


options[0].selected=true





}

}
function MySubjectDMA20(aMenu){

nullOptionsDMA(aMenu)



with (aMenu){



//Rewrites the text and values

options[0]=new Option("Select a page","none");

options[1]=new Option("Questions","Questions");

options[2]=new Option("Complaints","Complaints");

options[3]=new Option("Comments","Comments");

options[4]=new Option("Suggestions","Suggestions");


options[0].selected=true





}

}
function MySubjectDMA21(aMenu){

nullOptionsDMA(aMenu)



with (aMenu){



//Rewrites the text and values

options[0]=new Option("Select a page","none");

options[1]=new Option("Questions","Questions");

options[2]=new Option("Complaints","Complaints");

options[3]=new Option("Comments","Comments");

options[4]=new Option("Suggestions","Suggestions");


options[0].selected=true





}

}
function MySubjectDMA22(aMenu){

nullOptionsDMA(aMenu)



with (aMenu){



//Rewrites the text and values

options[0]=new Option("Select a page","none");

options[1]=new Option("Questions","Questions");

options[2]=new Option("Complaints","Complaints");

options[3]=new Option("Comments","Comments");

options[4]=new Option("Suggestions","Suggestions");


options[0].selected=true





}

}




/* ####################### goDM() ####################### */



function goDMA(aMenu){

if (aMenu.options.value!="none")

{

location=aMenu.options[aMenu.selectedIndex].value

}



}



/* ####################### setUp ####################### */



function setUpDMA(){

with (document.formDoubleMenuDMA) {

if (strDept.selectedIndex==0){

strDept.options[0].selected=true

strSubject.options[0].selected=true

}



if (strDept.selectedIndex==1)

MySubjectDMA0(strSubject)

if (strDept.selectedIndex==2)

MySubjectDMA1(strSubject)

if (strDept.selectedIndex==3)

MySubjectDMA2(strSubject)

if (strDept.selectedIndex==4)

MySubjectDMA3(strSubject)

if (strDept.selectedIndex==5)

MySubjectDMA4(strSubject)

if (strDept.selectedIndex==6)

MySubjectDMA5(strSubject)

if (strDept.selectedIndex==7)

MySubjectDMA6(strSubject)

if (strDept.selectedIndex==8)

MySubjectDMA7(strSubject)

if (strDept.selectedIndex==9)

MySubjectDMA8(strSubject)

if (strDept.selectedIndex==10)

MySubjectDMA9(strSubject)

if (strDept.selectedIndex==11)

MySubjectDMA10(strSubject)

if (strDept.selectedIndex==12)

MySubjectDMA11(strSubject)

if (strDept.selectedIndex==13)

MySubjectDMA12(strSubject)

if (strDept.selectedIndex==14)

MySubjectDMA13(strSubject)

if (strDept.selectedIndex==15)

MySubjectDMA14(strSubject)

if (strDept.selectedIndex==16)

MySubjectDMA15(strSubject)

if (strDept.selectedIndex==17)

MySubjectDMA16(strSubject)



}

}



/* ####################### changeFiles ####################### */



function changeFilesDMA(){

aMenu=document.formDoubleMenuDMA.strDept

aMenu2=document.formDoubleMenuDMA.strSubject

with (aMenu){



switch (selectedIndex) {

case 0:

aMenu2.options.length=0;

aMenu2.options[0]=

new Option("Pages appear here","none")

aMenu2.options[0].selected=true;

history.go(0)

break

case 1:

MySubjectDMA0(aMenu2)

aMenu2.options[0].text="Select a Subject"

break

case 2:

MySubjectDMA1(aMenu2)

aMenu2.options[0].text="Select a Subject"

break

case 3:

MySubjectDMA2(aMenu2)

aMenu2.options[0].text="Select a Subject"

break

case 4:

MySubjectDMA3(aMenu2)

aMenu2.options[0].text="Select a Subject"

break

case 5:

MySubjectDMA4(aMenu2)

aMenu2.options[0].text="Select a Subject"

break

case 6:

MySubjectDMA5(aMenu2)

aMenu2.options[0].text="Select a Subject"

break

case 7:

MySubjectDMA6(aMenu2)

aMenu2.options[0].text="Select a Subject"

break

case 8:

MySubjectDMA7(aMenu2)

aMenu2.options[0].text="Select a Subject"

break

case 9:

MySubjectDMA8(aMenu2)

aMenu2.options[0].text="Select a Subject"

break

case 10:

MySubjectDMA9(aMenu2)

aMenu2.options[0].text="Select a Subject"

break

case 11:

MySubjectDMA10(aMenu2)

aMenu2.options[0].text="Select a Subject"

break

case 12:

MySubjectDMA11(aMenu2)

aMenu2.options[0].text="Select a Subject"

break

case 13:

MySubjectDMA12(aMenu2)

aMenu2.options[0].text="Select a Subject"

break

case 14:

MySubjectDMA13(aMenu2)

aMenu2.options[0].text="Select a Subject"

break

case 15:

MySubjectDMA14(aMenu2)

aMenu2.options[0].text="Select a Subject"

break

case 16:

MySubjectDMA15(aMenu2)

aMenu2.options[0].text="Select a Subject"

break

case 17:

MySubjectDMA16(aMenu2)

aMenu2.options[0].text="Select a Subject"

break

case 18:

MySubjectDMA17(aMenu2)

aMenu2.options[0].text="Select a Subject"

break




}

}



}

//-->

</script>
<meta name="Microsoft Theme" content="internet 011, default">
<meta name="Microsoft Border" content="t">
</head>

<body onLoad="setUpDMA()">
<FORM name="formDoubleMenuDMA" method="post"
action="../department_forms/webmail_send.asp">
<input type="hidden" name="ipAddress"
value="<%Response.Write(ipAddress)%>">
<table border="0" cellpadding="0" style="border-collapse:
collapse" width="66%" id="table2">
<tr>
<td>
<u><b><font face="Verdana, Arial, Helvetica, sans-serif"
size="2">Email Your
Comments or Complaints<br>
</font></b></u><font face="Verdana, Arial, Helvetica, sans-serif"
size="2">You can
use this form to email your comments or notify the County of a
complaint which you may have. Select the department and subject from

the drop down menus provided to help us route your email to the
proper County office. Please enter a valid email address. If you
wish to be contacted other than by email, please include your
address and phone number in the comment area.</font></td>
</tr>
</table>
<p align="left">
<b>

<TABLE width="543" border="0" id="table1">
<TR>
<TD width="179" valign="middle">
<DIV align="right">

<font face="Verdana, Arial, Helvetica, sans-serif" size="2">Your
email
address: </font> </DIV>
</TD>
<TD width="354">
<INPUT type="text" name="strFromAddress"
onblur="checkEmail(strFromAddress)" size="40" tabindex="1"><br>
<span ID="nameSPAN2"
style="font-size:8pt;font-face:verdana"></span></TD>
</TR>
<TR>
<TD width="179" valign="middle">
<DIV align="right">
<font face="Verdana, Arial, Helvetica, sans-serif"
size="2">Department
to Contact: </font></DIV>
</TD>
<TD width="354">

<select name="strDept" onChange="changeFilesDMA()">

<option value="none" >Select a department

<option value="911 Management"> 911 Management</option>
<option value="Animal Center"> Animal Center</option>
<option value="Building"> Building Dept</option>
<option value="Code Enforcement"> Code Enforcement</option>
<option value="Community Services"> Community Services</option>
<option value="Development Review"> Engineering</option>
<option value="Drainage"> Engineering</option>
<option value="Fleet"> Fleet Management</option>
<option value="GIS"> GIS</option>
<option value="Master Gardener"> Master Gardener</option>
<option value="Parks and Recreation"> Parks and Recreation</option>
<option value="Planning"> Planning Department</option>
<option value="Public Affairs"> Public Affairs</option>
<option value="Right of Way"> Right of Way</option>
<option value="Roads"> Road Department</option>
<option value="Solid Waste"> Solid Waste</option>
<option value="Survey"> Survey</option>
<option value="Transportation"> Transportation</option>
<option value="Traffic"> Traffic</option>
<option value="Utilities"> Utilities</option>
<option value="VA"> Veterans Affairs</option>
<option value="VetPark"> Veterans Park</option>
<option value="Zoning"> Zoning Department</option>


</select></TD>
</TR>
<TR>
<TD width="179" valign="middle">
<DIV align="right"><FONT size="2" face="Verdana, Arial, Helvetica,
sans-serif">
Mail Subject: </FONT> </DIV>
</TD>
<TD width="354">
<!-- <INPUT type="text" name="strSubject" size="40"> <br>-->
<select name="strSubject" onblur="validField()" style="width:300">
<span ID="nameSPAN1" style="font-size:8pt;font-face:verdana" ></span>

<option value="none"> Select a Subject
</select></TD>
</TR>
<TR>
<TD width="179" valign="middle" height="207">
<DIV align="right">
<FONT face="Verdana, Arial, Helvetica, sans-serif" size="2">
Comments:</FONT></DIV>
</TD>
<TD width="354" rowspan="2">
<TEXTAREA name="strBody" cols="40" rows="15"></TEXTAREA>
</TD>
</TR>
<TR>
<TD valign="middle"></TD>
</TR>

</TABLE>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<INPUT type="submit" name="Submit" value="SUBMIT" onClick="return
validField()">&nbsp;&nbsp;&nbsp;&nbsp;
<input type="reset" value=" RESET "
onmouseover="style.color='red'" onmouseout="style.color='black'" style=
"cursor:hand;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="button" name="Button" value=" EXIT "
onClick="cancel_cmd()" onmouseover="style.color='red'"
onmouseout="style.color='black'" style=
"cursor:hand;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</FORM>

</body>

</html>
 
J

Joakim Braun

I get nameSPAN1 is undefined when I place cursor in comments box..

<%@ LANGUAGE="VBScript" %>
<% DIM ipAddress
ipAddress=Request.Servervariables("REMOTE_HOST")
%>
<snip>

....fourteen hundred lines of unedited code?

Clean it up, reduce it to essentials (the least code that still gives you
the error), then come back.

Joakim Braun
 
L

Laurent Bugnion

Hi,

I get nameSPAN1 is undefined when I place cursor in comments box..

Come on... can't you post an extract of your code, with only the
relevant lines?

I found the error anyway, but don't expect me to answer you again if you
don't learn how to post intelligently.

nameSPAN1 is undefined. You must use document.getElementById to get a
reference on the node, and then only you can use the properties, for
example innerHtml (though I wouldn't do that, rather use DOM Level 2
instead, for example myNode.firstChild.nodeValue).

HTH,

Laurent
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top