Selected value from dropdown menu wont display.
Hey people.
I'm baffled by this because it would seem a simple enough problem and yet I've been at it for a few days now.
The code below is supposed to display a value from the database, on the selection of a value in a drop down menu. Basically, if name is chosen from the drop down menu field (also extracted from db) then the department of the person selected should appear.
The department does appear, but the name of the selected person does not.
And when this code is used a few times in the same form, all the selected values in the different drop down menu dont appear.
If i use onchange, it refreshes the entire page and all the other selections made are lost (ie- checkboxes/text input etc).
The code is-
<TR class=colheader >
<td colspan=6 CLASS=template >Postage Mode:</td>
<tr class = form>
<TD> </TD>
<td valign=top>
<input type="radio" name="postmode" value="Normal" checked> Normal<br>
Franked by:
<%
Response.Write "<select name='lstName' >"
Response.Write "<OPTION value=-1>---Select one---" & "</OPTION>"
strfields = cstnewpic
set obj = objHR.RunQuery(tbpicm ,strfields)
if obj.recordcount then
obj.movefirst
for i =0 to obj.recordcount-1
if strname = obj(cstnewpic ) then
Response.Write "<option value ='" & obj(cstnewpic ) & "'>" & obj(cstnewpic ) & "</option>"
else
Response.Write "<option value ='" & obj(cstnewpic ) & "'>" & obj(cstnewpic ) & "</option>"
end if
obj.movenext
next
end if
obj.close
Response.Write "</select>"
%>
<br>
<input type="radio" name="postmode" value="arreg">AR Registered<br>
<input type="radio" name="postmode" value="poslaju">Pos Laju<br>
<input type="radio" name="postmode" value="other">Others<br>
<i>Please specify:</i>
<input name="specify"><br>
</td>
</tr>
<TR class=form>
<TD class ="" width="20%">Remarks:</TD>
<TD border="1" width="85%" class=normal>
<input name="time" size="100" ></TD>
</TR>
<TR class=colheader >
<td colspan=6 CLASS=template >Senders Details</td>
<tr class = form>
<TR class=form>
<TD class ="" width="20%">Requester Name:</TD>
<td>
<%
Response.Write "<select name='requester' onselect='document.frmPost.submit();' >"
Response.Write "<OPTION value=-1>---Select one---" & "</OPTION>"
strfields = cstName
set obj = objCESB.RunQuery(tbHRMS,strfields)
if obj.recordcount then
obj.movefirst
for i =0 to obj.recordcount-1
if strname = obj(cstName ) then
Response.Write "<option value ='" & obj(cstName ) & "'>" & obj(cstName ) & "</option>"
else
Response.Write "<option value ='" & obj(cstName ) & "'>" & obj(cstName ) & "</option>"
end if
obj.movenext
next
end if
obj.close
Response.Write "</select>"
%>
</td>
</TR>
<TR class=form>
<TD class ="" width="20%">Department: </TD>
<td>
<%
strwhere = cstName &"='"& strR &"'"
set obj = objCESB.RunQuery(tbHRMS,cstDept,strwhere)
if obj.recordcount then
for i =0 to obj.recordcount-1
Response.Write obj(cstDept)
Next
i = 1
end if
%>
</td>
</TR>
<TR class=form>
<TD class ="" width="20%">Date
</TD>
<TD border="1" width="85%" class=normal>
<input name="time" style="WIDTH: 160px; HEIGHT: 22px"></TD>
</TR>
<TR class=form>
<TD class ="" width="20%">Time: </TD>
<TD border="1" width="85%" class=normal>
<input name="time" style="WIDTH: 161px; HEIGHT: 22px"></TD>
</TR>
<TR class=form>
<TD class ="" width="20%">Telephone Ext:
</TD>
<td border="1" width="85%" class=normal>
<input name="time" style="WIDTH: 161px; HEIGHT: 22px"></td>
</TR>
<TR class=form>
<TD class ="" width="20%">Cost Center:
</TD>
<td> </td>
</TR>
<TR class=form>
<TD class ="" width="20%">Remarks </TD>
<TD border="1" width="85%" class=normal>
<input name="time" size="100" ></TD>
</TR>
<TR class=colheader >
<td colspan=6 CLASS=template >Postage Information Details</td>
<tr class = form>
<td class ="" width="20%"> Company name: </td>
<td>
<%
Response.Write "<select name='compadd' onchange='document.frmPost.submit();' >"
Response.Write "<OPTION value=-1>---Select one---" & "</OPTION>"
strfields = cstVcomp
set obj = objVmaster.RunQuery(tbVmaster,strfields)
if obj.recordcount then
obj.movefirst
for i =0 to obj.recordcount-1
if strname = obj(cstVcomp ) then
Response.Write "<option value ='" & obj(cstVcomp ) & "'>" & obj(cstVcomp ) & "</option>"
else
Response.Write "<option value ='" & obj(cstVcomp ) & "'>" & obj(cstVcomp ) & "</option>"
end if
obj.movenext
next
end if
obj.close
Response.Write "</select>"
%>
</td></tr>
<tr class=form>
<td class ="" width="20%">Company Address: </td>
<td>
<%
strfields = cstVaddr & "," & cstVaddr2
strwhere = cstVcomp &"='"& strCO &"'"
set obj = objVmaster.RunQuery(tbVmaster,strfields,strwhere)
if obj.recordcount then
for i =0 to obj.recordcount-1
Response.Write obj(cstVaddr)
'Response.Write obj(cstVaddr2)
Next
'i = 1
end if
%>
</td></tr>
<tr class=form>
<td class ="" width="20%">Cheque: </td>
<td valign=top>
<input type="radio" name="cheque" value="Yes" checked> Yes <br>
<input type="radio" name="cheque" value="No">No<br>
</td>
</tr>
<tr class=form>
<td class ="" width="20%">Cost of Postage: </td>
<TD border="1" width="85%" class=normal>
<input name="time"
style="WIDTH: 163px; HEIGHT: 22px" size=19></TD></tr>
<tr class=form>
<td class ="" width="20%">Remarks: </td>
<TD border="1" width="85%" class=normal>
<input name="time" size="100" ></TD>
</tr>
I'd appreciate any help or pointers. Im a bit too new to at ASP. Thanks.
|