|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here! |
|
#1
|
|||
|
|||
|
Hi All,
Brief Desc : This will display all records in PropSec table order by SecSort column which has values like '01', '02', '03', '04' and etc. The reason for this is that i want to sort the records according to the SecSort, '01' first followed by '02' and so on. There musn't be a same value in the drop down box. The no. of records can increase, & not necessary fix to 3 records only. MS Access db design : Secsort = text(2) Title = text(20) Expected Outcome : I would want to check to see that the user does not select the same value twice, i.e to prompt out an error message if it does. I am really confused as how to do a dynamic checking when there is no specific field name to check against. The checking can be done in the secsort.asp or secsort_rs.asp. As long as it can detect the same values & prompt error msg, i am very happy. Thanks in advance for all who have viewed or replied to my message. * included is a graphic file for easier understanding. ==== Start Code ==== Code:
<%
'secsort.asp
set rsSort = Server.CreateObject("ADODB.Recordset")
rsSort.open "SELECT Title,SecSort from PropSec order by SecSort", con,Adopenstatic
%>
<html>
<form action="secsort_rs.asp" method="post" name="frmSecSort">
<table>
<tr>
<td width="5%"><span style="<%=spanNm%>"></span></td>
<td width="10%"><span style="<%=spanNm%>"><b>Sort</b></span></td>
<td width="85%"><span style="<%=spanNm%>"><b>Title</b></span></td>
</tr>
<%
smax=rsSort.recordcount
while not rsSort.eof
sTitle = trim(rsSort("Title"))
sSecSort = trim(rsSort("SecSort"))
%>
<tr>
<td width="5%"></td>
<td width="10%"><select size="1" name="SType<%=sSecSort%>">
<%
set rsSort2 = Server.CreateObject("ADODB.Recordset")
rsSort2.open "SELECT SecSort from PropSec order by SecSort", con,Adopenstatic
while not rsSort2.eof
%>
<option <%if sSecSort=trim(rsSort2("SecSort")) then%>selected<%end if%>><%=trim(rsSort2("SecSort"))%></option>
<%
rsSort2.movenext
wend
rsSort2.close
set rsSort2=nothing%>
</select></td>
<td width="85%"><span style="<%=spanNm%>"><%=sTitle%></span></td>
</tr>
<%
rsSort.movenext
wend
rsSort.close
set rsSort=nothing
%>
</table>
</form>
==== End Code ==== |
|
#2
|
|||
|
|||
|
call me stupid, but i don't really get it, let me ask you this, why can't you just check on the page is submits to
loop through request.form with beginning, then beginnign + 1 and so up. Then if they're equal, set bool = false. |
|
#3
|
|||
|
|||
|
that wuz what i thought at first, to loop until all is done. But my problem really lies on the checking of the drop down list.
if i know how many records, then it would be easier. but the records are not fixed. Therefore, to check for the same value (01, 02, 03,...) entered and generate error msg would be harder. e.g Code:
a01 = trim(request.form("SType01"))
a02 = trim(request.form("SType02"))
:
a0n = trim(request.form("STypen"))
if a01=a02 or a01=a03 or ..... or a01=a0n then
' print error msg
end if
This (above) would be hard coding the variables. but we wouldn't know the n value as the records can be hundreds or more. If my n value is known or just a few records, then the easy way out is to hard code it, but i can't. The variables below (on the left side) can't be dynamically generated, can it? The right side can be done, but left side? a<%=i%> = trim(request.form("SType"& i) if it can, then my question can be solve. otherwise, back to drawing board. ![]() if still cannot, then i have to find another way to handle this situation. thanks for helping out. |
|
#4
|
|||
|
|||
|
No, you have to do it with a bool
Start with bool = false you have two loops, inner iterator j, outer i. you have 6 slots w/ 6 values 1 2 3 4 5 6 if you start with loop one (i) on 1, and loop two on (j) on i+1 it goes like this Code:
if array(i) = array(j) then
bool = true
end if
then at end where message goes Code:
if bool then response.write errormsg() end if |
|
#5
|
|||
|
|||
|
great, thanks.
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > Validation for Dynamic Drop Down? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|