What's happening:
When Select all button is clicked the hidden variable, buttonname, is
supposed to be set to all and the form is submitted to itself. If the
buttonname = 'all' then all of the checkboxes are supposed to be displayed as
checked. However the buttonname variable is not holding it's value. When I
view the final source after submitting the form, the buttonname variable is
empty. I didn't know what group to post this in since my code contains both
vbscript and javascript. If you can help I'd very much appreciate it.
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>StarNet - E-mail Admin</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<SCRIPT LANGUAGE="JavaScript">
function submitthis ( selectedtype )
{
document.list.buttonname.value = selectedtype ;
document.list.submit() ;
}
-->
</script>
<% getCon=Application("connectionObject")
'type is true if an ecard and false if a newsletter.
dim objrs,bool,mailer
set objrs=server.CreateObject("adodb.recordset")
set objGroups=server.CreateObject("adodb.recordset")
set objContest=server.createobject("adodb.recordset")
objrs.open "select * from addstarnet where username ='" & session("whois")
& "' order by groupname",getcon,3,3
If isnull(session("agentid")) or session("agentid") = "" or
isempty(session("agentid")) then
contestcontacts = false
else
objContest.open "select * from contest where agentid = '" &
session("agentid") & "'",getcon,3,3
If not objContest.eof then
contestContacts = true
objContest.movefirst
else
contestContacts = false
end if
end if
If not objrs.eof then
bool = true
objrs.movefirst
objGroups.open "select distinct groupname from addstarnet where username =
'" & session("whois") & "' order by groupname", getcon,3,3
objGroups.movefirst
else
bool = false
end if
%>
</head>
<body>
<table width="638" border="1" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="634" height="236" valign="top" bgcolor="#FFFFFF"><div
align="center">
<table width="634" border="0" cellpadding="0" cellspacing="0"
style="margin-bottom:0">
<tr>
<td width="634"><div align="center"><img src="images/S.gif"
width="40" height="65"><img src="images/t.gif" width="50" height="65"><img
src="images/a.gif" width="64" height="65"><img src="images/r.gif" width="50"
height="65"><img src="images/n.gif" width="54" height="65"><img
src="images/e.gif" width="48" height="65"><img src="images/t.gif" width="50"
height="65"></div></td>
</tr>
<tr>
<td><div align="center"><font color="#996600">E-mail Postcard and
Newsletter System</font></div></td>
</tr>
<tr>
<td bgcolor="#CCCCCC"><strong><font color="#000000">Step 4 - Send
to... </font></strong></td>
</tr>
<tr>
<td valign="top"> <p align="center"> </p>
<p align="center"><a href="email_admin.asp">Add/Delete/Edit
E-mail
Addresses</a></p>
<% If bool = true then%>
<form action="step4.asp" method="post"
enctype="multipart/form-data" name="list">
<table width="530" border="1" align="center" cellpadding="1"
cellspacing="1">
<tr bgcolor="#CCCCCC">
<td colspan="4" bgcolor="#CCCCCC"><a
href="javascript:submitthis('all')">Select
All </a> -<a href="javascript:getsupport('Free')">
Delete
Selected</a> - <a
href="javascript:getsupport('Free')">Select
Contest Contacts Only</a></td>
</tr>
<%response.write(request("mailer"))
For i = 1 to objGroups.recordcount%>
<tr bgcolor="#CCCCCC">
<td colspan="4" bgcolor="#FFFFFF"><font size="2">
<input name="buttonname" type="hidden" value="">
<input name="list<%response.write(i)%>"
type="checkbox" id="list<%response.write(i)%>"
value="<%response.write(objGroups("groupname"))%>" <%If request("buttonname")
= "all" or request("list" & i) = objGroups("groupname") then
response.write("checked")%>>
<%response.write(objGroups("groupname"))%>
</font></td>
</tr>
<% b = 1
Do until objGroups("groupname") <> objrs("groupname")%>
<tr bgcolor="#CCCCCC">
<td width="45" bgcolor="#FFFFFF"><div
align="right"><font size="2">
<input name="list<%response.write(i & "-" & b)%>"
type="checkbox" id="list<%response.write(i & "-" & b)%>"
value="<%response.write(objrs("email"))%>" <%If request("buttonname") = "all"
or request("list" & i) = objGroups("groupname") then
response.write("checked")%>>
<%b=b+1%>
</font></div></td>
<td width="135"
bgcolor="#FFFFFF"><%response.write(objrs("first"))%></td>
<td width="145"
bgcolor="#FFFFFF"><%response.write(objrs("last"))%></td>
<td width="195"
bgcolor="#FFFFFF"><%response.write(objrs("email"))%></td>
</tr>
<%objrs.movenext
if objrs.eof then exit do
loop
objGroups.movenext
Next
if contestContacts = true then%>
<tr bgcolor="#CCCCCC">
<td colspan="4" bgcolor="#FFFFFF"><font size="2">
<input name="contest" type="checkbox" id="contest"
value="Contest Contacts">
Contest Contacts
</font></td>
</tr>
<%For i = 1 to objContest.recordcount%>
<tr bgcolor="#CCCCCC">
<td width="45" bgcolor="#FFFFFF"><div
align="right"><font size="2">
<input name="list<%response.write("c-" & i)%>"
type="checkbox" id="list" value="<%response.write(objcontest("emailadd"))%>">
</font></div></td>
<td width="135"
bgcolor="#FFFFFF"><%response.write(objcontest("firstname"))%></td>
<td width="145"
bgcolor="#FFFFFF"><%response.write(objcontest("lastname"))%></td>
<td width="195"
bgcolor="#FFFFFF"><%response.write(objcontest("emailadd"))%></td>
</tr>
<%objcontest.movenext
next
end if
%>
</table>
<input name="mailer" type="hidden"
value="<%response.write(request("mailer"))%>">
<div align="center"><br>
<input name="image" type="image" src="images/next.gif"
alt="submit form" width="87" height="32">
</div>
</form>
<%end if%> </td>
</tr>
</table>
</div></td>
</tr>
</table>
</body>
</html>