Active Server Pages Programming (ASP)/ASP radio button query
Expert: Srini Nagarajan - 10/11/2011
QuestionQUESTION: suppose we have a list of accounts from which some are expired and some are not expired. and whole list of expired and not expired is in xml file and we want to display through a radio button in asp so that if we click on expire then rxpired list to be shown and if we click on not expired then not expired list to be shown..how can dat be done?
ANSWER: Hi,
I believe you are using classic asp
Here is the logic
Dim objxml
Set objxml = Server.CreateObject("Microsoft.XMLDOM")
objxml.async = False
objxml.load (Server.MapPath("GiveYourXMlFileName"))
set ElemValue1 = objxml.getElementsByTagName("property")
set ElemValue2 = objxml.getElementsByTagName("property/type/en")
set ElemValue3 = objxml.getElementsByTagName("property/town/en")
set ElemValue4 = objxml.getElementsByTagName("property/province/en")
For i=0 To (ElemProperty.length -1)
if ElemValue1.item(i).Text = "Expired" and expiredRadioButtonChecked then
Display all expired elemvalues
end if
if ElemValue1.item(i).Text = "Not Expired" and NotexpiredRadioButtonChecked then
Display all not expired values....
end if
next
Set objxml = Nothing
Happy programming
Cheers
-Srini
---------- FOLLOW-UP ----------
QUESTION: actually the problem is the page already has a button named "get destinations"and when we click on it, it gives the list of all expired and not expired accounts and i want a radio button so that if I select expired radiooption so i should get only expired accounts and same in case of not expired. and i dont want to use any other button for the clicking i just want to do that with the same "get destinations" button. i used this code..
<form name="frmSearch" method="post" runat="server">
<table border="1" cellpadding="2" cellspacing="0" align="left" style="width: 656px">
<tr bgcolor="#C0C0C0" >
<td colspan="2">
Search by CLI: </td>
</tr>
<tr>
<td bgColor=#f5f5f5 align=left>CLI:</td>
<td bgColor=#f5f5f5 align=left nowrap >
<input type=text name=txtcli id=txtPin />    
<input type="submit" name="btnCli" value="Get Destinations" style="font-size:7pt; font-family: Verdana; padding:0px; margin:0px; background:#D7D4F0">
</td>
<td> <form action="
http://172.16.18.13/servicerest/expiredestination.php?action=getdestsandcli&cli=("cli")&"&pin="&request.QueryString("pin")&"view="& >
<input type="radio" name="radiobutton1" value="expired"> Expired    
<input type="radio" name="radiobutton1" value="not expired"> Not Expired
<input type="submit" name="btnCli" value="Get Destinations" style="font-size:7pt; font-family: Verdana; padding:0px; margin:0px; background:#D7D4F0">
</form>
</td>
</tr>
</table>
</form>
<%
if request.Form("btnCli")<>"" then
response.Redirect "/TAMS/Customer_Service/Search/viewDestinations.asp?opt=cli&cli="&request("txtcli")&"&pin="&request("pin")
end if
%>
AnswerHi,
As I explained, you need to filter in the for each loop which one you want to display...
add two radio buttons and a button on click of the button add a validation, here is the link gives you how to get which one clicked and display accordingly
http://www.asp101.com/samples/viewasp.asp?file=radiobutton.asp
Cheers
-Srini