Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_web_howto thread: combo box: dealing w/ multiselect


Message #1 by "Sukhi" <sukhdeepsamra@h...> on Tue, 23 Oct 2001 19:11:23
I have 10 different titles stored in one table:



Title_code|Title_description

1	Project Manager

2	Senior Manager

3	Director

4	Assistant

5 	CFN Designate

6 	Analyst

7 	acting Director



I have a combo box on title.asp page which shows all these titles from 

tbltitle.



user can multiselect these titles. But i have business rules for titles, 

which are



1)Senior manager can be acting Director

2)Director can be CFN Designate

3)all other can have only one title assigned to them



if person has selected senior manager and assistant. I want to display 

error saying this is not allowed..



is anyone of you have done somthing like that already? know any 

examples/sites? etc. It would be gr888 help...



Thanks in advance..



Sukhi 



----------->This is how my code looks like ...........



If Len(Request.Form("cmdadd")) Then 



	arrayTC=split(Request("cboTitle"), ",")

	for i=0 to ubound(arrayTC)

	'this is to display the array

	'response.write arrayTC(i) 



	mysql10= "Select Mem_ID, Title_Code from tblTitle_Associate where 

Mem_ID='"&request("Mem_ID") & "'  AND Title_Code='"&arrayTC(i)&"' "

	set rs10=conn.execute(mySQL10)



	  if  rs10.eof then

        

        	if arrayTC(i)=1 Then

			mySQLNeg= "INSERT INTO tblTitle_Associate

(Mem_ID,Title_Code) Values('"&request("Mem_ID") & "',  '1') "

			set rsNeg=conn.execute(mySQLNeg)

		end if



		if arrayTC(i)=2 Then

			if arrayTC(i)=2 Then

				mySQLSN= "INSERT INTO tblTitle_Associate

(Mem_ID,Title_Code) Values('"&request("Mem_ID") & "',  '2') "

				set rsSN=conn.execute(mySQLSN)

			end if



			if arrayTC(i)=9 Then

				mySQLSN= "INSERT INTO tblTitle_Associate

(Mem_ID,Title_Code) Values('"&request("Mem_ID") & "',  '9') "

				set rsSN=conn.execute(mySQLSN)

			end if

		end if



	if arrayTC(i)=3 Then

			if arrayTC(i)=3 Then

				mySQLSN= "INSERT INTO tblTitle_Associate

(Mem_ID,Title_Code) Values('"&request("Mem_ID") & "',  '3') "

				set rsSN=conn.execute(mySQLSN)

			end if



			if arrayTC(i)=6 Then

				mySQLSN= "INSERT INTO tblTitle_Associate

(Mem_ID,Title_Code) Values('"&request("Mem_ID") & "',  '6') "

				set rsSN=conn.execute(mySQLSN)

			end if



	end if

         

         	if arrayTC(i)=4 or arrayTC(i)=5 or arrayTC(i)=7 or arrayTC

(i)=8 Then

			if arrayTC(i)=4 Then

				mySQLSN= "INSERT INTO tblTitle_Associate

(Mem_ID,Title_Code) Values('"&request("Mem_ID") & "',  '4') "

				set rsSN=conn.execute(mySQLSN)

			end if



			if arrayTC(i)=5 Then

				mySQLSN= "INSERT INTO tblTitle_Associate

(Mem_ID,Title_Code) Values('"&request("Mem_ID") & "',  '5') "

				set rsSN=conn.execute(mySQLSN)

			end if



			if arrayTC(i)=7 Then

				mySQLSN= "INSERT INTO tblTitle_Associate

(Mem_ID,Title_Code) Values('"&request("Mem_ID") & "',  '7') "

				set rsSN=conn.execute(mySQLSN)

			end if



			if arrayTC(i)=8 Then

				mySQLSN= "INSERT INTO tblTitle_Associate

(Mem_ID,Title_Code) Values('"&request("Mem_ID") & "',  '8') "

				set rsSN=conn.execute(mySQLSN)

			end if



	end if





%>











Message #2 by Vaibhav Bhan <vbhan_00@y...> on Tue, 23 Oct 2001 12:24:02 -0700 (PDT)
 Sukhi,

Try to use javascript (On Blur) event to check for the selected indexes and raise an error accordingly. Hope this helps

Vibhu

  Sukhi <sukhdeepsamra@h...> wrote: I have 10 different titles stored in one table:



Title_code|Title_description

1 Project Manager

2 Senior Manager

3 Director

4 Assistant

5 CFN Designate

6 Analyst

7 acting Director



I have a combo box on title.asp page which shows all these titles from 

tbltitle.



user can multiselect these titles. But i have business rules for titles, 

which are



1)Senior manager can be acting Director

2)Director can be CFN Designate

3)all other can have only one title assigned to them



if person has selected senior manager and assistant. I want to display 

error saying this is not allowed..



is anyone of you have done somthing like that already? know any 

examples/sites? etc. It would be gr888 help...



Thanks in advance..



Sukhi 



----------->This is how my code looks like ...........



If Len(Request.Form("cmdadd")) Then 



arrayTC=split(Request("cboTitle"), ",")

for i=0 to ubound(arrayTC)

'this is to display the array

'response.write arrayTC(i) 



mysql10= "Select Mem_ID, Title_Code from tblTitle_Associate where 

Mem_ID='"&request("Mem_ID") & "' AND Title_Code='"&arrayTC(i)&"' "

set rs10=conn.execute(mySQL10)



if rs10.eof then



if arrayTC(i)=1 Then

mySQLNeg= "INSERT INTO tblTitle_Associate

(Mem_ID,Title_Code) Values('"&request("Mem_ID") & "', '1') "

set rsNeg=conn.execute(mySQLNeg)

end if



if arrayTC(i)=2 Then

if arrayTC(i)=2 Then

mySQLSN= "INSERT INTO tblTitle_Associate

(Mem_ID,Title_Code) Values('"&request("Mem_ID") & "', '2') "

set rsSN=conn.execute(mySQLSN)

end if



if arrayTC(i)=9 Then

mySQLSN= "INSERT INTO tblTitle_Associate

(Mem_ID,Title_Code) Values('"&request("Mem_ID") & "', '9') "

set rsSN=conn.execute(mySQLSN)

end if

end if



if arrayTC(i)=3 Then

if arrayTC(i)=3 Then

mySQLSN= "INSERT INTO tblTitle_Associate

(Mem_ID,Title_Code) Values('"&request("Mem_ID") & "', '3') "

set rsSN=conn.execute(mySQLSN)

end if



if arrayTC(i)=6 Then

mySQLSN= "INSERT INTO tblTitle_Associate

(Mem_ID,Title_Code) Values('"&request("Mem_ID") & "', '6') "

set rsSN=conn.execute(mySQLSN)

end if



end if



if arrayTC(i)=4 or arrayTC(i)=5 or arrayTC(i)=7 or arrayTC

(i)=8 Then

if arrayTC(i)=4 Then

mySQLSN= "INSERT INTO tblTitle_Associate

(Mem_ID,Title_Code) Values('"&request("Mem_ID") & "', '4') "

set rsSN=conn.execute(mySQLSN)

end if



if arrayTC(i)=5 Then

mySQLSN= "INSERT INTO tblTitle_Associate

(Mem_ID,Title_Code) Values('"&request("Mem_ID") & "', '5') "

set rsSN=conn.execute(mySQLSN)

end if



if arrayTC(i)=7 Then

mySQLSN= "INSERT INTO tblTitle_Associate

(Mem_ID,Title_Code) Values('"&request("Mem_ID") & "', '7') "

set rsSN=conn.execute(mySQLSN)

end if



if arrayTC(i)=8 Then

mySQLSN= "INSERT INTO tblTitle_Associate

(Mem_ID,Title_Code) Values('"&request("Mem_ID") & "', '8') "

set rsSN=conn.execute(mySQLSN)

end if



end if





%>












  Return to Index