W
WC Justice
I am building a site using ASP and some javascript (to make data entry
easier). I use ASP to create a recordset consisting of ProjectID,
ProjectName, and ProjectMileageRate, and the option box is built from the
recordset. I would like for the txtBillingItemMileageRate field on the form
to be populated with the ProjectMileageRate based on the ProjectID selected
in the combo box. I have experimented enough to see that I can mix ASP and
Javascript as in the following (it is currently triggered by a hyperlink for
experimentation purposes):
function jsUpdateMileageRate() {
document.frmBillingEntries.txtBillingItemMileageRate.value =
<%=rsUserProjects("ProjectMileageRate")%> ;
}
This function works fine, except that it is simply taking the first
ProjectMileageRate of the recordset.
The following is the code used to create the recordset and option box.
<td width="25%"><font size="2"><select size="1" name="optProject"
onBlur="javascript:jsUpdateTotals()" style="text-align: left; float: left;
font: 10">
<%
SET conn = server.createobject ("adodb.connection")
conn.open "DSN=" & Session("DSN")
SET rsUserProjects = Server.CreateObject("ADODB.Recordset")
rsUserProjects.CursorLocation = 3
strSQL = "SELECT tblUserProjectAuthority.UserID, tblProjects.ProjectName,
tblProjects.ProjectMileageRate," _
& "tblUserProjectAuthority.ProjectID,
tblUserProjectAuthority.UserProjectActive " _
& "FROM tblProjects INNER JOIN tblUserProjectAuthority ON " _
& "tblProjects.ProjectID = tblUserProjectAuthority.ProjectID " _
& "WHERE (((tblUserProjectAuthority.UserID)='" & Session("UserID") & "') AND
" _
& "((tblUserProjectAuthority.UserProjectActive)=True));"
rsUserProjects.open strSQL,conn
do until rsUserProjects.EOF
%>
<option
<%=rsUserProjects("ProjectID")%>><%=rsUserProjects("ProjectName")%></option>
<%
rsUserProjects.MOVENEXT
LOOP
%>
</select></font></td>
</tr>
<%
rsUserProjects.CLOSE
SET rsUserProjects = NOTHING
%>
Is there a way to populate the txtBillingItemMileageRate field with the
mileage rate associated with the selected Project? If so, please advise.
Also, I would appreciate any constructive criticism of the existing code.
Thanks
easier). I use ASP to create a recordset consisting of ProjectID,
ProjectName, and ProjectMileageRate, and the option box is built from the
recordset. I would like for the txtBillingItemMileageRate field on the form
to be populated with the ProjectMileageRate based on the ProjectID selected
in the combo box. I have experimented enough to see that I can mix ASP and
Javascript as in the following (it is currently triggered by a hyperlink for
experimentation purposes):
function jsUpdateMileageRate() {
document.frmBillingEntries.txtBillingItemMileageRate.value =
<%=rsUserProjects("ProjectMileageRate")%> ;
}
This function works fine, except that it is simply taking the first
ProjectMileageRate of the recordset.
The following is the code used to create the recordset and option box.
<td width="25%"><font size="2"><select size="1" name="optProject"
onBlur="javascript:jsUpdateTotals()" style="text-align: left; float: left;
font: 10">
<%
SET conn = server.createobject ("adodb.connection")
conn.open "DSN=" & Session("DSN")
SET rsUserProjects = Server.CreateObject("ADODB.Recordset")
rsUserProjects.CursorLocation = 3
strSQL = "SELECT tblUserProjectAuthority.UserID, tblProjects.ProjectName,
tblProjects.ProjectMileageRate," _
& "tblUserProjectAuthority.ProjectID,
tblUserProjectAuthority.UserProjectActive " _
& "FROM tblProjects INNER JOIN tblUserProjectAuthority ON " _
& "tblProjects.ProjectID = tblUserProjectAuthority.ProjectID " _
& "WHERE (((tblUserProjectAuthority.UserID)='" & Session("UserID") & "') AND
" _
& "((tblUserProjectAuthority.UserProjectActive)=True));"
rsUserProjects.open strSQL,conn
do until rsUserProjects.EOF
%>
<option
<%=rsUserProjects("ProjectID")%>><%=rsUserProjects("ProjectName")%></option>
<%
rsUserProjects.MOVENEXT
LOOP
%>
</select></font></td>
</tr>
<%
rsUserProjects.CLOSE
SET rsUserProjects = NOTHING
%>
Is there a way to populate the txtBillingItemMileageRate field with the
mileage rate associated with the selected Project? If so, please advise.
Also, I would appreciate any constructive criticism of the existing code.
Thanks