Click to See Complete Forum and Search --> : I need a little guidance


erjohns
05-06-2005, 03:19 PM
I think I've got this working. The goal is to access a section from a drop down list and manipulate it to yield the proper text in a table. I'm not including the entire code as only what I'm including here applies. Please look it over and tell me if I'm on the right track.

page: default.asp

<% language = "VBSCRIPT" %>
<!-- #include file = " ../calculate.asp" -->
<%
units= "Imperial"
If (Request.QueryString("meas") = "nM-m" or
(Request.QueryString("meas") = "Nm) Then
units = "Metric"
Else units = "Imperial"
End If
%>

<html>
<body>

<table border = 1>
<tr>
<form action="default.asp" method = "post">
<td colspan = 2>
<select id = "meas" name = "meas" onChange="<% meas=Request.form("meas")>
<option value = " " selected=selected> </option>
<option value = "oz-in"> oz-in </option>
<option value = "lb-in"> lb-in </option>
<option value = "nM-m"> nM-m </option>
<option value = "Nm> Nm </option>
</select>
<input name ="allSubmit" type = "submit" id = "allSubmit4" value = "View New Data">
</td>
</form>
</tr>
</table>

<hr>
<hr>
<table border = 1 width = "40%">
<tr>
<td><% = Tmaxu %></td>
<td><% = Tcsu %></td>
<td><% = Tfmaxu %></td>
<td><% = Tpu %></td>
<td><% = Kmu %></td>
<td><% = Jmsensu %></td>
<td><% = whu %></td>
<td><% = wfu %></td>
</tr>
</table>
</body>
</html>



page calculate.asp

<%
Dim Tmaxu, Tfmaxu, Tpu, Kmu, Jmsensu, whu, wfu

Tmaxu = Request.QueryString("meas")
Tcu = Request.QueryString("meas")
Tfmaxu = Request.QueryString("meas")
Tpu = Request.QueryString("meas")
Kmu = Request.QueryString("meas")

if Request.QueryString("units") = "metric" Then
Jmsensu = " g-cm &sup2; "
whu = "g"
wfu = "g"
Else
Jmsensu = "oz-S &sup2; &times; 10 &sup; -4"
whu = "oz"
wfu = "oz"

%>


Keep in mind I've marked where one page ends and the other begins and both HAVE to be in use for this to work right.

Thanks in advance

Eric

buntine
05-06-2005, 09:40 PM
Looks pretty good.

You are missing the closing quote on the if statement at the top. Change it to this:

If (Request.QueryString("meas") = "nM-m" or
(Request.QueryString("meas") = "Nm") Then
units = "Metric"
Else units = "Imperial"
End If

I'm not sure what your trying to do here:

<select id = "meas" name = "meas" onChange="<% meas=Request.form("meas")>

Remember, ASP code cannot be executed from the client. And JavaScript code cannot be executed from the server.

Regards.

erjohns
05-11-2005, 12:13 PM
<select id = "meas" name = "meas" onChange="<% meas=Request.form("meas")>


What I need to do here is assign the selected value to a variable which can then be used in other operations. Basically it should work like this:

User selects from drop down list
That value is entered into various places in a table
The value is also used to determine the type so that a different measurement can be determined and then posted to the same table.

I've since made some changes before reading your reply. Here's what I've got:

calculate.asp

<%
Dim Tmaxu, Tfmaxu, Tpu, Kmu, Jmsensu, whu, wfu, Tcu, units, init
init = Request.QueryString(default.asp("UoM"))
If init = "nM-m" Then
units = "Metric"
else if init = "Nm" Then
units = "Metric"
Else units = "Imperial"
End If

sub UofM()
Tmaxu = init
Tcu = init
Tfmaxu = init
Tpu = init
Kmu = init

if units = "metric" Then
Jmsensu = " g-cm <sup>2</sup> "
whu = "g"
wfu = "g"
Else
Jmsensu = "oz-S <sup>2</sup> X 10 <sup>-4</sup>"
whu = "oz"
wfu = "oz"
End if
end sub
%>

default.asp

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!-- #include file = "calculate.asp" -->

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>

<%
call UofM()
%>


<table border = 1>
<tr>
<form action="default.asp" method = "post">
<td colspan = 2>
<select id = "meas" name = "meas" onChange="<% UoM=Request.form("meas")%>">
<option value = " " selected=selected> </option>
<option value = "oz-in"> oz-in </option>
<option value = "lb-in"> lb-in </option>
<option value = "nM-m"> nM-m </option>
<option value = "Nm"> Nm </option>
</select>
<input name ="allSubmit" type = "submit" id = "allSubmit4" value = "View New Data">
</td>
</form>
</tr>
</table>

<hr>
<hr>
<table border = 1 width = "40%">
<tr>
<td><% = Tmaxu %></td>
<td><% = Tcsu %></td>
<td><% = Tfmaxu %></td>
<td><% = Tpu %></td>
<td><% = Kmu %></td>
<td><% = Jmsensu %></td>
<td><% = whu %></td>
<td><% = wfu %></td>
<td><% = UoM %></td>
<td><% = units %></td>

</tr>
</table>

</body>

</html>

buntine
05-11-2005, 09:28 PM
You need to understand that your ASP code cannot interact with JavaScript in this way. The ASP code in the onchange event will be executed before the page is even sent to the client machine.
Take a look at the HTML source code that is generated. You will see that there is just a value in the onchange event (onchange="somevalue").

The form needs to be submitted so the page can be sent to the server for processing. You process from the server and then return the new page with the value inserted into the table.

Regards.

erjohns
05-12-2005, 12:13 PM
Thank you for your help. Between your suggestions and those made in another thread I had going I have my problem solved. So for now I've got it. I just need to impliment it into the actual page now.