ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old September 28th, 2003, 10:46 PM
pda8333 pda8333 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 216 pda8333 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 6 m 31 sec
Reputation Power: 5
Question Validation for Dynamic Drop Down?

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 ====
Attached Images
File Type: gif pda8333.gif (4.3 KB, 265 views)

Reply With Quote
  #2  
Old October 1st, 2003, 11:19 PM
unatratnag unatratnag is offline
Average Intelligence
Dev Shed Novice (500 - 999 posts)
 
Join Date: Apr 2003
Location: Ohio/Chicago
Posts: 678 unatratnag User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 m 22 sec
Reputation Power: 6
Send a message via AIM to unatratnag
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.

Reply With Quote
  #3  
Old October 2nd, 2003, 12:28 AM
pda8333 pda8333 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 216 pda8333 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 6 m 31 sec
Reputation Power: 5
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.

Reply With Quote
  #4  
Old October 2nd, 2003, 01:08 AM
unatratnag unatratnag is offline
Average Intelligence
Dev Shed Novice (500 - 999 posts)
 
Join Date: Apr 2003
Location: Ohio/Chicago
Posts: 678 unatratnag User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 m 22 sec
Reputation Power: 6
Send a message via AIM to unatratnag
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

Reply With Quote
  #5  
Old October 2nd, 2003, 07:31 PM
pda8333 pda8333 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 216 pda8333 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 6 m 31 sec
Reputation Power: 5
great, thanks.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > Validation for Dynamic Drop Down?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway