Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 21st, 2010, 09:57 AM
Registered User
 
Join Date: Mar 2010
Posts: 9
Thanks: 1
Thanked 0 Times in 0 Posts
Default Set qry string value based on radio btn selected

I have a page that i need to sort if the user selects the sort radio btn and then hit the link to reload the page.

I want to pass a 1 in the querystring for sort if the rb is checked and no querystring if the rb isnt checked.

How can i do this?
also once the rb is selected when i click it a second time it doesnt unselect

I just inherited a classic asp site and have 1 week experiance so all the help u can give apreciated

Thanks!
<%@ Language=VBScript %>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<%
dim sort, strSQL
sort=Request.QueryString("sort")

if sort=1 then
strSQL = strSQL & "ORDER BY Date Desc"
else
strSQL = strSQL & "ORDER BY fName"
end if
%>

<div id="SelFra" style="POSITION: absolute; WIDTH: 100%;">
<table width ="100%" border="0" cellspacing="0" align="center" >
<tr bgcolor="#aeaeae" >
<td style="width:200px;">&nbsp;&nbsp;
<input type="radio" name="rbSort" value="0"
<% IF sort=1 then Response.Write "Checked" end if %> />&nbsp;&nbsp;Sort by Account Size&nbsp;&nbsp;
</td>
<td>
<a href="Default22.asp?sort=1" >Image</a>
</td>
</tr>
</table>
</div>
</body>
</html>
 
Old March 21st, 2010, 05:51 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

You shoulf post form variables as a first option. Querystrings should be used as little as possible. A whole nother topic there, trust me...

You could use an anchor tag and simply pass a QS. I have placed a <form> there and altered your code to achieve your objectivewitha form variable. Also you need to use a checkbox and not a radio button. You can turn a radio button off when there is only one option, you would need two radio buttons!!!

Anyhow - just rename pageName.asp to your page name in the "action'" part of the form tag. Apart from that the code is cut n paste

<%
dim sort, strSQL
sort = ""
sort=Request.form("rbSort")
if sort <> "" then
strSQL = strSQL & "ORDER BY Date Desc"
else
strSQL = strSQL & "ORDER BY fName"
end if
%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<div id="SelFra" style="POSITION: absolute; WIDTH: 100%;">
<form name="updateForm" action="pageName.asp" method="post">
<table width ="100%" border="0" cellspacing="0" align="center" >
<tr bgcolor="#aeaeae" >
<td style="width:200px;">&nbsp;&nbsp;<input type="checkbox" name="rbSort" <% if sort <> "" then response.write " checked " end if %> value="1" />&nbsp;&nbsp;Sort by Account Size&nbsp;&nbsp;</td>
<td><input type="submit" value="Sort"></td>
</tr>
</table>
</form>
</div>
</body>
</html>
__________________
Wind is your friend
Matt
 
Old March 21st, 2010, 05:59 PM
Registered User
 
Join Date: Mar 2010
Posts: 9
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Sweet, thanks buddy, it took me all day to figure out what you said, and its good to confirm i ended up in the right place.

Thank you very much!


Quote:
Originally Posted by mat41 View Post
You shoulf post form variables as a first option. Querystrings should be used as little as possible. A whole nother topic there, trust me...

You could use an anchor tag and simply pass a QS. I have placed a <form> there and altered your code to achieve your objectivewitha form variable. Also you need to use a checkbox and not a radio button. You can turn a radio button off when there is only one option, you would need two radio buttons!!!

Anyhow - just rename pageName.asp to your page name in the "action'" part of the form tag. Apart from that the code is cut n paste

<%
dim sort, strSQL
sort = ""
sort=Request.form("rbSort")
if sort <> "" then
strSQL = strSQL & "ORDER BY Date Desc"
else
strSQL = strSQL & "ORDER BY fName"
end if
%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<div id="SelFra" style="POSITION: absolute; WIDTH: 100%;">
<form name="updateForm" action="pageName.asp" method="post">
<table width ="100%" border="0" cellspacing="0" align="center" >
<tr bgcolor="#aeaeae" >
<td style="width:200px;">&nbsp;&nbsp;<input type="checkbox" name="rbSort" <% if sort <> "" then response.write " checked " end if %> value="1" />&nbsp;&nbsp;Sort by Account Size&nbsp;&nbsp;</td>
<td><input type="submit" value="Sort"></td>
</tr>
</table>
</form>
</div>
</body>
</html>





Similar Threads
Thread Thread Starter Forum Replies Last Post
2 Radio btn with one Submit btn, convert to 2 Btn ismailc XSLT 2 August 15th, 2008 07:00 AM
Use a frm based on a qry to update a tbl Brucifier Access 1 August 8th, 2006 10:06 PM
Page display based on radio button selected Mekala HTML Code Clinic 3 July 10th, 2004 06:12 AM
display value of selected radio in the textbox hosefo81 Javascript How-To 1 February 1st, 2004 07:57 AM
Prb: COUNT qry result NOT SAME as SELECT qry savoym SQL Language 5 July 2nd, 2003 04:44 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.