need a way to make the page do a refresh instead of a submit to populate the categorylist form element cos at this moment of the code on select of the main directory it inserts into the database which is not suppose to do so
even in the form tag i set the MM_insert to null and initialized it in the javascript submitForm method but it doesnt inserts anything wat to do
<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="Connections/strConne
ctString.a
sp" -->
<%
' *** Edit Operations: declare variables
Dim MM_editAction
Dim MM_abortEdit
Dim MM_editQuery
Dim MM_editCmd
Dim MM_editConnection
Dim MM_editTable
Dim MM_editRedirectUrl
Dim MM_editColumn
Dim MM_recordId
Dim MM_fieldsStr
Dim MM_columnsStr
Dim MM_fields
Dim MM_columns
Dim MM_typeArray
Dim MM_formVal
Dim MM_delim
Dim MM_altVal
Dim MM_emptyVal
Dim MM_i
MM_editAction = CStr(Request.ServerVariabl
es("SCRIPT
_NAME"))
If (Request.QueryString <> "") Then
MM_editAction = MM_editAction & "?" & Request.QueryString
End If
' boolean to abort record edit
MM_abortEdit = false
' query string to execute
MM_editQuery = ""
%>
<%
' *** Insert Record: set variables
If (CStr(Request("MM_insert")
) = "form1") Then
MM_editConnection = MM_strConnectString_STRING
MM_editTable = "Directory_Reg"
MM_editRedirectUrl = ""
MM_fieldsStr = "business_name|value|busin
ess_addres
s|value|bu
siness_des
cription|v
alue|conta
ct_name|va
lue|mobile
|value|tel
ephone|val
ue|email|v
alue|odeta
ils|value|
Main|value
|CategoryL
ist|value|
Listing|va
lue"
MM_columnsStr = "Business_Name|',none,''|B
usiness_Ad
dress|',no
ne,''|Busi
ness_Descr
iption|',n
one,''|Con
tact_Name|
',none,''|
Mobile|',n
one,''|Tel
ephone|',n
one,''|Ema
il|',none,
''|[Other Details]|',none,''|Main_Di
rectory|',
none,''|Di
rectory_Ty
pe|',none,
''|Listing
_Type|',no
ne,''"
' create the MM_fields and MM_columns arrays
MM_fields = Split(MM_fieldsStr, "|")
MM_columns = Split(MM_columnsStr, "|")
' set the form values
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_fields(MM_i+1) = CStr(Request.Form(MM_field
s(MM_i)))
Next
' append the query string to the redirect URL
If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
End If
End If
End If
%>
<%
' *** Insert Record: construct a sql insert statement and execute it
Dim MM_tableValues
Dim MM_dbValues
If (CStr(Request("MM_insert")
) <> "") Then
' create the sql insert statement
MM_tableValues = ""
MM_dbValues = ""
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_formVal = MM_fields(MM_i+1)
MM_typeArray = Split(MM_columns(MM_i+1),"
,")
MM_delim = MM_typeArray(0)
If (MM_delim = "none") Then MM_delim = ""
MM_altVal = MM_typeArray(1)
If (MM_altVal = "none") Then MM_altVal = ""
MM_emptyVal = MM_typeArray(2)
If (MM_emptyVal = "none") Then MM_emptyVal = ""
If (MM_formVal = "") Then
MM_formVal = MM_emptyVal
Else
If (MM_altVal <> "") Then
MM_formVal = MM_altVal
ElseIf (MM_delim = "'") Then ' escape quotes
MM_formVal = "'" & Replace(MM_formVal,"'","''
") & "'"
Else
MM_formVal = MM_delim + MM_formVal + MM_delim
End If
End If
If (MM_i <> LBound(MM_fields)) Then
MM_tableValues = MM_tableValues & ","
MM_dbValues = MM_dbValues & ","
End If
MM_tableValues = MM_tableValues & MM_columns(MM_i)
MM_dbValues = MM_dbValues & MM_formVal
Next
MM_editQuery = "insert into " & MM_editTable & " (" & MM_tableValues & ") values (" & MM_dbValues & ")"
If (Not MM_abortEdit) Then
' execute the insert
Set MM_editCmd = Server.CreateObject("ADODB
.Command")
MM_editCmd.ActiveConnectio
n = MM_editConnection
MM_editCmd.CommandText = MM_editQuery
MM_editCmd.Execute
MM_editCmd.ActiveConnectio
n.Close
If (MM_editRedirectUrl <> "") Then
Response.Redirect(MM_editR
edirectUrl
)
End If
End If
End If
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><!-- InstanceBegin template="/Templates/MainI
nfo.dwt" codeOutsideHTMLIsLocked="f
alse" -->
<head>
<!-- InstanceBeginEditable name="doctitle" -->
<title></title>
<%
dim strDataPath, strConnectString, objConnection
dim strMain, strCategoryList, objRS, strSelected, strSQL
strMain = Request.Form("Main")
strCategoryList = Request.Form("CategoryList
")
sub makeMain()
Dim ObjRS
Dim ObjRS_numRows
Set ObjRS = Server.CreateObject("ADODB
.Recordset
")
ObjRS.ActiveConnection = MM_strConnectString_STRING
ObjRS.Source = "SELECT Distinct Dir_Name FROM Main_Dir ORDER BY Dir_Name"
ObjRS.CursorType = 0
ObjRS.CursorLocation = 2
ObjRS.LockType = 1
ObjRS.Open()
ObjRS_numRows = 0
Response.Write("<option></
option>" & VBCRLF )
do while not objRS.EOF
if objRS("Dir_Name") = strMain then
strSelected = " Selected "
else
strSelected = ""
end if
Response.Write("<option" & strSelected & ">" &_
objRS("Dir_Name") & "</option>" & VBCRLF )
objRS.MoveNext
loop
objRS.Close
set objRS=Nothing
end sub
sub makeCategoryList
if strMain <> "" then
Dim ObjRS
Dim ObjRS_numRows
Set ObjRS = Server.CreateObject("ADODB
.Recordset
")
ObjRS.ActiveConnection = MM_strConnectString_STRING
ObjRS.Source = "SELECT DISTINCT Directory_Menu FROM Sub_Main_Dir WHERE Dir_Name = '" &_
strMain & "' ORDER BY Directory_Menu"
ObjRS.CursorType = 0
ObjRS.CursorLocation = 2
ObjRS.LockType = 1
ObjRS.Open()
ObjRS_numRows = 0
if objRS.eof then
Response.Write("<option>No
Categories Found</option>")
else
Response.Write("<option>Se
lect Category Now</option>" & VBCRLF )
do while not objRS.EOF
if objRS("Directory_Menu") <> "" then
strSelected = " Selected "
else
strSelected = ""
end if
Response.Write("<option" & strSelected & ">" &_
objRS("Directory_Menu") & "</option>" & VBCRLF )
objRS.MoveNext
loop
end if
objRS.Close
set objRS=Nothing
else
Response.Write("<option>Se
lect a Directory First</option>")
end if
end sub
%>
<script language="JavaScript">
<!--
function submitMain(){
var objForm = document.forms[0];
objForm.elements['Category
List'].sel
ectedIndex
=0;
objForm.submit();
}
function submitForm(){
var objForm = document.forms[0];
objForm.action = "index.asp";
return true;
}
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&p
arent.fram
es.length)
{
d=parent.frames[n.substrin
g(p+1)].do
cument; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;
i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.
layers.len
gth;i++) x=MM_findObj(n,d.layers[i]
.document)
;
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_validateForm() { //v4.0
var i,p,q,nm,test,num,min,max,
errors='',
args=MM_va
lidateForm
.arguments
;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
if (val) { nm=val.name; if ((val=val.value)!="") {
if (test.indexOf('isEmail')!=
-1) { p=val.indexOf('@');
if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
} else if (test!='R') { num = parseFloat(val);
if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test.substring(p+1);
if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
} if (errors) alert('The following error(s) occurred:\n'+errors);
document.MM_returnValue = (errors == '');
}
//-->
</script>
<!-- InstanceEndEditable -->
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
<style type="text/css">
<!--
@import url("StyleSheets/Text.css"
);
-->
</style>
</head>
<body link="#0000FF" topmargin="1">
<table width="1018" height="773" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="109" colspan="3" valign="top"><div align="right">
<table width="1020" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="left" valign="top"><img src="graphics/New/Template
/banner.jp
g" width="1020" height="104" border="0" usemap="#Map"></td>
</tr>
</table>
</div></td>
</tr>
<tr align="left">
<td height="15" colspan="3"><table width="1020" height="19" border="0" cellpadding="0" cellspacing="0" background="graphics/New/T
emplate/ce
llbkgrd.jp
g">
<tr>
<td height="19"> </td>
</tr>
</table></td>
</tr>
<tr>
<td width="185" height="585" align="left" valign="top" class="MediumTxt"><div align="left"></div>
<table width="178" border="0" cellspacing="2">
<tr>
<td align="left"><!-- InstanceBeginEditable name="text3" --><!-- InstanceEndEditable --></td>
</tr>
<tr>
<td width="172" align="left"><div align="left"><a href="TheLook.htm"><img src="graphics/images/menul
ook.gif" width="170" height="28" border="0"></a></div></td>
</tr>
<tr>
<td align="left"><div align="left"><a href="money.htm"><img src="graphics/images/menum
oney.gif" width="170" height="28" border="0"></a></div></td>
</tr>
<tr>
<td align="left"><div align="left"><a href="lifestyles.htm"><img
src="graphics/images/menul
ife.gif" width="170" height="28" border="0"></a></div></td>
</tr>
<tr>
<td align="left"><div align="left"><a href="directory.htm"><img src="graphics/images/menud
irect.gif"
width="170" height="28" border="0"></a></div></td>
</tr>
<tr>
<td align="left"><div align="left"><a href="essentials.htm"><img
src="graphics/images/menue
ssential.g
if" width="170" height="28" border="0"></a></div></td>
</tr>
<tr>
<td align="left"><div align="left"><img src="graphics/images/menue
vent.gif" width="170" height="28"></div></td>
</tr>
<tr>
<td height="23" align="left"><div align="left"><a href="BookReview.htm"><img
src="graphics/images/menub
ooks.gif" width="170" height="28" border="0"></a></div></td>
</tr>
<tr>
<td align="left"><div align="left"><a href="Forum.htm"><img src="graphics/images/menuc
onnection.
gif" width="170" height="28" border="0"></a></div></td>
</tr>
<tr>
<td align="left"><div align="left"><a href="contactus.htm"><img src="graphics/images/menuc
ontact.gif
" width="170" height="28" border="0"></a></div></td>
</tr>
<tr>
<td align="left"><div align="left"><a href="members.htm"><img src="graphics/images/menum
ember.gif"
width="170" height="28" border="0"></a></div></td>
</tr>
<tr>
<td align="left"><div align="left"><a href="aboutus.htm"><img src="graphics/images/menua
bout.gif" width="170" height="28" border="0"></a></div></td>
</tr>
<tr>
<td height="74" align="center"><a href="index.htm"><img src="graphics/images/menuh
ome.gif" width="96" height="30" border="0"></a></td>
</tr>
</table></td>
<td width="591" align="left" valign="top"><table width="585" border="0">
<tr>
<td width="581" align="left" valign="top"><!-- InstanceBeginEditable name="text1" -->
<div align="center"><br>
<br>
<img src="graphics/New/Subtitle
s/direcReg
.jpg" width="269" height="29">
</div>
<!-- InstanceEndEditable --></td>
</tr>
<tr>
<td height="105" valign="top"><!-- InstanceBeginEditable name="text2" --><br>
<form ACTION="<%=MM_editAction%>
" method="POST" name="form1" onSubmit="return submitForm()">
<table width="75%" border="0" align="center" cellpadding="0">
<tr>
<td width="33%" class="MediumTxt">Business
Name</td>
<td width="67%" class="MediumTxt"> <input name="business_name" type="text" id="business_name" size="40"value="<%=Request
.Form("bus
iness_name
")%>"></td
>
</tr>
<tr>
<td class="MediumTxt">Business
Address</td>
<td class="MediumTxt"> <textarea name="business_address" cols="30" rows="6" id="business_address"><%=R
equest.For
m("busines
s_address"
)%></texta
rea></td>
</tr>
<tr>
<td class="MediumTxt">Business
Description</td>
<td class="MediumTxt"> <textarea name="business_description
" cols="30" rows="6" id="business_description">
<%=Request
.Form("bus
iness_desc
ription")%
></textare
a></td>
</tr>
<tr>
<td class="MediumTxt">Contact Name</td>
<td class="MediumTxt"> <input name="contact_name" type="text" id="contact_name" value="<%=Request.Form("co
ntact_name
")%>" size="40"></td>
</tr>
<tr>
<td class="MediumTxt">Mobile</
td>
<td class="MediumTxt"> <input name="mobile" type="text" id="mobile" value="<%=Request.Form("mo
bile")%>" size="40"></td>
</tr>
<tr>
<td class="MediumTxt">Telephon
e</td>
<td class="MediumTxt"> <input name="telephone" type="text" id="telephone" value="<%=Request.Form("te
lephone")%
>" size="40"></td>
</tr>
<tr>
<td class="MediumTxt">Email</t
d>
<td class="MediumTxt"> <input name="email" type="text" id="email" value="<%=Request.Form("em
ail")%>" size="40"></td>
</tr>
<tr>
<td class="MediumTxt">Other Details</td>
<td class="MediumTxt"><input name="odetails" type="text" id="odetails2" value="<%=Request.Form("od
etails")%>
" size="40"></td>
</tr>
<tr>
<td class="MediumTxt">Director
y Type</td>
<td class="MediumTxt"><select name="Main" id="Main" onChange="JavaScript:submi
tMain();">
<%call makeMain%>
</select></td>
</tr>
<tr>
<td class="MediumTxt">Category
</td>
<td class="MediumTxt"><select name="CategoryList" id="CategoryList">
<%call makeCategoryList%>
</select></td>
</tr>
<tr>
<td class="MediumTxt"> Listing Type</td>
<td class="MediumTxt"><select name="Listing" id="Listing">
<option selected>Select One</option>
<option value="Free">Free Listing</option>
<option value="Paid">Paid Listing</option>
</select> </td>
</tr>
<tr align="center">
<td colspan="2"> <p> </p>
<p>
<input name="Submit" type="submit" onClick="MM_validateForm('
business_n
ame','','R
','contact
_name','',
'R','mobil
e','','R',
'telephone
','','R','
email','',
'RisEmail'
,'odetails
2','','R',
'business_
address','
','R','bus
iness_desc
ription','
','R');ret
urn document.MM_returnValue" value="Submit Information">
</p></td>
</tr>
</table>
<p> </p>
<p> </p>
<p> </p>
<input type="hidden" name="MM_insert" value="form1">
</form>
<br>
<!-- InstanceEndEditable --></td>
</tr>
</table></td>
<td width="242" align="right" valign="top"><object classid="clsid:D27CDB6E-AE
6D-11cf-96
B8-4445535
40000" codebase="
http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="242" height="585">
<param name="movie" value="flash/home%20naviga
tion2.swf"
>
<param name="quality" value="high">
<embed src="flash/home%20navigati
on2.swf" quality="high" pluginspage="
http://www.macromedia.com/go/getflashplayer" type="application/x-shockw
ave-flash"
width="242" height="585"></embed></obj
ect></td>
</tr>
<tr bgcolor="#CC3333">
<td height="6" colspan="3" align="center" valign="top" class="smalltxt">3</td>
</tr>
<tr>
<td height="53" align="center" valign="top"> </td>
<td align="center" valign="top" class="smalltxt1"><div align="center" class="smalltxt2"><br>
©2003 mylifestylesolutions.com. A product of Media Business Company
<br>
74 Raymond Njoku Street, Ikoyi, Lagos. +234 803 325 4159<br>
Re-Designed by<font color="#0000FF"> <a href="
http://www.bizdatausa.com">BIZ
DATAUSA
Inc.</a></font></div></td>
<td align="right" valign="top"> </td>
</tr>
</table>
<map name="Map">
<area shape="rect" coords="5,31,134,48" href="login.asp">
<area shape="rect" coords="6,50,161,67" href="membership.htm">
</map>
</body>
<!-- InstanceEnd --></html>
Start Free Trial