Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: Re: HELP - ASP drop down with SQL server


Message #1 by "Thang Hoang" <thang_hoang_88@h...> on Thu, 7 Mar 2002 04:31:02
I tried to place the value into an input type hidden like you said. The 

problem is when the data from the db is preselected, how do you place it ?



I have a teacher profile with name, deptno, title... a table for the dept 

with deptno and deptname...I am displaying this for an update. So I 

created a drop down for the dept which use the dept table...this drop down 

will show the current dept for the teacher from the db...but how do I 

place the deptno into a hidden input when the drop down is loaded ?



I hope you understand my explanation.



<option value="<%=ucase(RSPressCat(0))%>" <%if trim(RSPressCat(0)) = trim

(categoriescode) then Response.Write("selected")%> ><%=ucase(RSPressCat

(1)) & VBCRLF %>





> One way to do it is place the db values into a <input type=hidden> tag.

> 

> ----- Original Message -----

> From: "Thang Hoang" <thang_hoang_88@h...>

> To: "ASP Databases" <asp_databases@p...>

> Sent: Thursday, March 07, 2002 3:53 AM

> Subject: [asp_databases] HELP - ASP drop down with SQL server

> 

> 

> > Need your help. Please show me the way.

> >

> > I have an asp page displaying data from SQL server. This page contains 

a

> > drop down list which receive data from the db. I was able to retrieve 

and

> > display the correct data in the drop down. It also select the 

department

> > assigned to the record for display; i.e. "teacher A" belong to dept

> > Physics . The info is retrieve for an UPDATE. The problem arises when 

the

> > modify/submit button is clicked. The values from the drop down were not

> > sent to the next page. If the dept is changed for that teacher then the

> > values are being passed. It's only when the dept stay the same for that

> > teacher that the values are not being passed or passed as blanks. My

> > question is how can I make it so that the value preselected from the db

> > are being passed to the next page on a submit ? Can someone help me

> > please ?

> >

> >

> >

> > <%

> >

> > sSQL = "SELECT deptno, deptname FROM dept WHERE deptno in 

(22,23,24,25,26)

> > ORDER BY deptno"

> > Set RSPress=ConnPress.Execute(sSQL)

> >

> > %>

> > <td align="left" valign="top">

> > <select name="DeptTXT" style="font: 12px 'arial';" onChange="change

();">

> > <option selected value=<%=sNo%>> <%=sDeptName%>

> > <%

> > Do While Not(RSPress.EOF)

> > %>

> > <option value="<%=ucase(RSPress(0))%>"><%=ucase(RSPress(1)) & VBCRLF %>

> > <%

> >   RSPress.MoveNext

> > LOOP

> > %>

> > </select>

> > </td>

> >

> >

> > -------------Javascript function

> >

> > function change()

> > {

> > var DeptTXTidx;

> > var sDeptvalue;

> >

> > DeptTXTidx = document.Insprofs.DeptTXT.selectedIndex;

> > sDeptvalue = document.Insprofs.DeptTXT

> > [document.Insprofs.DeptTXT.selectedIndex].value;

> > document.Insprofs.categoriescodeTXT.value = sDeptvalue;

> > }

> >

> >

> >

> >

> >




> $subst('Email.Unsub').

> >

> 

Message #2 by "James Garrett" <jhgarrett@e...> on Wed, 6 Mar 2002 21:12:05 -0500
One way to do it is place the db values into a <input type=hidden> tag.



----- Original Message -----

From: "Thang Hoang" <thang_hoang_88@h...>

To: "ASP Databases" <asp_databases@p...>

Sent: Thursday, March 07, 2002 3:53 AM

Subject: [asp_databases] HELP - ASP drop down with SQL server





> Need your help. Please show me the way.

>

> I have an asp page displaying data from SQL server. This page contains a

> drop down list which receive data from the db. I was able to retrieve and

> display the correct data in the drop down. It also select the department

> assigned to the record for display; i.e. "teacher A" belong to dept

> Physics . The info is retrieve for an UPDATE. The problem arises when the

> modify/submit button is clicked. The values from the drop down were not

> sent to the next page. If the dept is changed for that teacher then the

> values are being passed. It's only when the dept stay the same for that

> teacher that the values are not being passed or passed as blanks. My

> question is how can I make it so that the value preselected from the db

> are being passed to the next page on a submit ? Can someone help me

> please ?

>

>

>

> <%

>

> sSQL = "SELECT deptno, deptname FROM dept WHERE deptno in (22,23,24,25,26)

> ORDER BY deptno"

> Set RSPress=ConnPress.Execute(sSQL)

>

> %>

> <td align="left" valign="top">

> <select name="DeptTXT" style="font: 12px 'arial';" onChange="change();">

> <option selected value=<%=sNo%>> <%=sDeptName%>

> <%

> Do While Not(RSPress.EOF)

> %>

> <option value="<%=ucase(RSPress(0))%>"><%=ucase(RSPress(1)) & VBCRLF %>

> <%

>   RSPress.MoveNext

> LOOP

> %>

> </select>

> </td>

>

>

> -------------Javascript function

>

> function change()

> {

> var DeptTXTidx;

> var sDeptvalue;

>

> DeptTXTidx = document.Insprofs.DeptTXT.selectedIndex;

> sDeptvalue = document.Insprofs.DeptTXT

> [document.Insprofs.DeptTXT.selectedIndex].value;

> document.Insprofs.categoriescodeTXT.value = sDeptvalue;

> }

>

>

>

>

>




$subst('Email.Unsub').

>



Message #3 by "Thang Hoang" <thang_hoang_88@h...> on Thu, 7 Mar 2002 03:53:28
Need your help. Please show me the way.



I have an asp page displaying data from SQL server. This page contains a 

drop down list which receive data from the db. I was able to retrieve and 

display the correct data in the drop down. It also select the department 

assigned to the record for display; i.e. "teacher A" belong to dept 

Physics . The info is retrieve for an UPDATE. The problem arises when the 

modify/submit button is clicked. The values from the drop down were not 

sent to the next page. If the dept is changed for that teacher then the 

values are being passed. It's only when the dept stay the same for that 

teacher that the values are not being passed or passed as blanks. My 

question is how can I make it so that the value preselected from the db 

are being passed to the next page on a submit ? Can someone help me 

please ?







<%



sSQL = "SELECT deptno, deptname FROM dept WHERE deptno in (22,23,24,25,26) 

ORDER BY deptno" 

Set RSPress=ConnPress.Execute(sSQL)



%>

<td align="left" valign="top">

<select name="DeptTXT" style="font: 12px 'arial';" onChange="change();">

	<option selected value=<%=sNo%>> <%=sDeptName%>

<%

Do While Not(RSPress.EOF)

%>

<option value="<%=ucase(RSPress(0))%>"><%=ucase(RSPress(1)) & VBCRLF %>

<%

  RSPress.MoveNext

LOOP

%> 

</select>

</td> 





-------------Javascript function



function change()

{

var DeptTXTidx;

var sDeptvalue;



DeptTXTidx = document.Insprofs.DeptTXT.selectedIndex;

sDeptvalue = document.Insprofs.DeptTXT

[document.Insprofs.DeptTXT.selectedIndex].value;

	document.Insprofs.categoriescodeTXT.value = sDeptvalue;

}










  Return to Index