[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

ASP Dynamic Forms PRoblem (Submit Button Disappears)

Posted on 2005-04-07
2
Medium Priority
?
268 Views
Last Modified: 2008-07-03
Why does my submit button disappear when I view this page.  I think the code works but if you can't click submit what good is it.  I am dynamically building a dropdown list and whatever the person selects and click submit it will take them to that site.  Any advise on where the problem lies?

'*********************************************

<html>
<head>
<title>New Page 1</title>
<title>Search</title>
<SCRIPT LANGUAGE=javascript>
<!--
function setAction(strURL){
     document.forms[0].action = strURL;
}
//-->
</SCRIPT>
</head>
<body>
<FORM method=GET action="http://www.mylink.com/" target="_blank">
<select onChange=setAction(this.value)>
<%
strSQL = "SELECT LastName,FirstName,MyLink FROM People order by LastName"

Dim strconn
strconn="PROVIDER=MSDASQL;DRIVER={SQL Server};SERVER=Server;DATABASE=DB;UID=myID;PWD=myPass;"
Dim dbConn
Set dbConn = Server.CreateObject("ADODB.Connection")
dbConn.Open strconn    
     
Dim rs
Set rs = Server.CreateObject("ADODB.Recordset")
'Set rs = dbConn.Execute(strSQL)
rs.Open strSQL, dbConn,0,3
%>
<% if rs.BOF and rs.eof then %>
<option>no records</option>
<%
else
rs.MoveFirst
%><option></option>
<%
Do while not rs.eof
%>
<option value="<% Response.Write rs.Fields("MyLink") %>"><% Response.Write rs.Fields("FirstName") & " " & rs.Fields("LastName") %></option>
<%
rst1.MoveNext
Loop
end if
rs.Close
dbConn.Close
Set RS = Nothing
Set dbConn = Nothing
%>
</select><input type=submit name=sa value=Search>
</form>
</body>
</html>
0
Comment
Question by:tw_chase
  • 2
2 Comments
 
LVL 35

Accepted Solution

by:
YZlat earned 1000 total points
ID: 13726762
move the code there you close your connection to the end of file - after </html> tag,

add double quotes when calling javascript:

<select name="select1" onChange="setAction(this.value);">

Otherwise your page looks fine and your button should appear on the page. I've tested the page and it works fine.

Oops, also you had rst1.MoveNext instead of rs.MoveNext
0
 
LVL 35

Expert Comment

by:YZlat
ID: 13726802
I made minor changes to your code + put the controls inside a table. Try it now

<html>
<head>

<title>Search</title>
<SCRIPT LANGUAGE=javascript>
<!--
function setAction(strURL){
     document.forms[0].action = strURL;
}
//-->
</SCRIPT>
</head>
<body>


<FORM method=GET action="http://www.mylink.com/" target="_blank">
<%
strSQL = "SELECT LastName,FirstName,MyLink FROM People order by LastName"

Dim strconn
strconn="PROVIDER=MSDASQL;DRIVER={SQL Server};SERVER=Server;DATABASE=DB;UID=myID;PWD=myPass;"
Dim dbConn
Set dbConn = Server.CreateObject("ADODB.Connection")
dbConn.Open strconn    
     
Dim rs
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open strSQL, dbConn,0,3
%>
<table>
<tr>
<td>
<select onChange=setAction(this.value)>

<% if not (rs.BOF and rs.eof) then
      
      Do while not rs.eof
            %>
            <option value="<% Response.Write rs.Fields("MyLink") %>"><% Response.Write rs.Fields("FirstName") & " " & rs.Fields("LastName") %></option>
            <%
            rs.MoveNext
      Loop
else
      Response.write "no records to display"
      %>
      <option value="no records">No Records</option>
      <%
      
end if%>
</select>
</td>
<td>
<input type=submit name=sa value=Search>
</td.
</tr>
</table>
</form>
</body>
</html>
<%
rs.Close
dbConn.Close
Set RS = Nothing
Set dbConn = Nothing
%>
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question