Click to See Complete Forum and Search --> : check on opening page


il_betto
10-19-2010, 09:24 AM
Hi to All,
I have page.asp like this:

<%@ Language=VBScript %>
<% Option Explicit
Dim objConn, objRS, objRS2, rec, strSQL
%>

<html>
<head>
<Script Language="JavaScript">
function setLabel() {
if (document.forms[0].iss_sum.options[document.FrontPage_Form1.iss_sum.selectedIndex].text.match(/^Free/)) {
document.getElementById("label_des").style.display=""; }
else { document.getElementById("label_des").style.display="none"; }
}
</head>
<body>
<%
...
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.ConnectionString = "DSN=aom.dsn"
objConn.Open
'
Set objRS2 = Server.CreateObject("ADODB.Recordset")
objRS2.Open "t_mro", objConn, , 3, 2
Do While Not objRS2.EOF
If (objRS2("Num") = Cint(rec)) Then
strSQL = "SELECT * FROM t_mro WHERE Num = " & rec
Set objRS = objConn.Execute(strSQL)
End If
objRS2.MoveNext
nr = nr + 1
Loop
'
...
If objRS("Issue_Summary")="Free Text" Then ??????
%>
<form method="POST" webbot-onSubmit language="JavaScript" name="FrontPage_Form1">
...
<select id="iss_sum" name="iss_sum" onchange="setLabel()">
<option value="<%=objRS("Issue_Summary")%>" selected><%=objRS("Issue_Summary")%></option>
</select> <label for="iss_des" id="label_des" style="display:none; font-weight: bold; vertical-align:top">Description:
<font face="Gill Sans MT">
<textarea id="iss_des" name="iss_des"><%=objRS("Issue_Description")%></textarea></font>
</label>
...
</body>

My question is:
in which way, when I recall the page.asp via web,
if the field objRS("Issue_Summary") contains the string "Free",
then can be visible the field objRs("Issue_Description") with its label ??

Thanks in advance !!!

yamaharuss
10-19-2010, 09:38 AM
I don't see where you are declaring your objRS query outside of the loop..

il_betto
10-19-2010, 09:49 AM
Is there a different solution ??

yamaharuss
10-19-2010, 10:13 AM
According to your layout, the record should be looked at inside the loop instead of outside the loop

il_betto
10-19-2010, 10:52 AM
In this case,
please,
which is the correct sintax to make a visibility on the field objRS("Issue_Description") with its label ??

yamaharuss
10-19-2010, 11:27 AM
<%
...
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.ConnectionString = "DSN=aom.dsn"
objConn.Open
'
Set objRS2 = Server.CreateObject("ADODB.Recordset")
objRS2.Open "t_mro", objConn, , 3, 2
Do While Not objRS2.EOF
If (objRS2("Num") = Cint(rec)) Then
strSQL = "SELECT * FROM t_mro WHERE Num = " & rec
Set objRS = objConn.Execute(strSQL)
If objRS("Issue_Summary")="Free Text" Then
response.write "Yes, it is free tex<br>t"
Else
response.write "no, this one is not it.<br>"
End If
End If
objRS2.MoveNext
nr = nr + 1
Loop

%>

il_betto
10-20-2010, 04:51 AM
Thanks for your precious help !!!

The problem is now solved in this way:
the code remains the same as written the first time; it was added and improved only the code in red ...

<select id="iss_sum" name="iss_sum" onchange="setLabel()">
<option value="<%=objRS("Issue_Summary")%>" selected><%=objRS("Issue_Summary")%></option>
</select> <label for="iss_des" id="label_des" style="<% If objRS("Issue_Summary")<>"Free Text" Then Response.write("display:none;")%> font-weight: bold; vertical-align:top">Description:
<font face="Gill Sans MT">
<textarea id="iss_des" name="iss_des"><%=objRS("Issue_Description")%></textarea>font>
</label>


Thanks again !!!

:D

yamaharuss
10-20-2010, 06:04 AM
Your code will only work if the recordset exists in the last item in your loop. What if Free Text exists in the first item in the loop but not the second? Your solution does not make sense.