Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Help with ASP script, dropdown requery for response to first dropdown

Posted on 2011-09-07
27
Medium Priority
?
352 Views
Last Modified: 2012-05-12
I am re-entering the world of web app programming and trying to create a simple form that will allow a user to choose an option from a dropdown (fed by a sql query) then based on that selection populate a second dropdown.  In this case it is the first drop down showing a community name and the second should show lot numbers.  So far, the community names will show up just fine but I cannot figure out the syntax for the variable to pass in the name to get the lot numbers.  If I hard code a community name in the lot query.  The code is somewhat sloppy and I have tried moving the second query around but still with no luck.  Could someone take a look and see if anything stands out as being obvious??  Thanks.

<form action="websiteupdate_send.asp" METHOD="POST" name="frmData" onsubmit="return verifyData(this)">
<table border="0">
      <%      Dim rs
            Dim rt
            Dim sNhood
            Dim sLots
            Dim sRegion
            Dim sSQL
            Dim MyConn
            Dim sHTML
            Dim sHTNH
            Dim sHTL
            Dim NTLogin, sSender, sSentDate, sText
            NTLogin = Request.ServerVariables("AUTH_USER")
            if Left(NTLogin,7) = "JWHOMES" then
                  sSender = Right(NTLogin, len(NTLogin)-8) & "@jwhomes.com"
            else
                  sSender = NTLogin & "@jwhomes.com"
            end if
            Set oJWI = Server.CreateObject("JWIntranet.clsJWIntranet")
      
            sNhood = "select distinct neighborhoodname from homelinkii..neighborhoods where active = 1"
                    
            
            
            Set rt = oJWI.RunSQLReturnRS(sNhood)
            Do while not rt.eof
                  sHTNH = sHTNH & "<option value='" & rt("neighborhoodname") & "'"
                  sHTNH = sHTNH & ">" & rt("neighborhoodname") & "</option>"
                  rt.movenext
            Loop      
            
            Set rt = oJWI.RunSQLReturnRS(sLots)
            Do while not rt.eof
                  sHTL = sHTL & "<option value='" & rt("lotnumber") & "'"
                  sHTL = sHTL & ">" & rt("lotnumber") & "</option>"
                  rt.movenext
            Loop      

            
            %>

      
      <%
            set rs = nothing
            
            %>
      <tr><td height=25></td></tr>
            <tr>
            <td align="right">Neighborhood:</td>
            <td><select name="tNhood" ID="Select1"><option value="" selected>Select Neighborhood</option><%=sHTNH%></select></td>
      </tr>
            <% sLots = "select lotnumber from homelinkii..lots l join homelinkii..neighborhoods n on l.neighborhoodid = n.neighborhoodid where neighborhoodname = " & tNhood  
                  Set rt = oJWI.RunSQLReturnRS(sLots)
            Do while not rt.eof
                  sHTL = sHTL & "<option value='" & rt("lotnumber") & "'"
                  sHTL = sHTL & ">" & rt("lotnumber") & "</option>"
                  rt.movenext
            Loop      %>

            <tr>
            <td align="right">Lot:</td>
            <td><select name="tlot" ID="Select1"><option value="" selected>Select Lot</option><%=sHTL%></select></td>
      </tr>
0
Comment
Question by:JWHomes
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 12
  • 11
  • 4
27 Comments
 
LVL 54

Expert Comment

by:Scott Fell, EE MVE
ID: 36497106
0
 

Author Comment

by:JWHomes
ID: 36497234
I really need to use SQL to dynamically populate the drop downs as the values will constantly be changing
0
 
LVL 54

Expert Comment

by:Scott Fell, EE MVE
ID: 36497418
Exactly.  I use this all the time.  You just need to replace the static select with your own.  So where you see

<select id="mark">
  <option value="">--</option>
  <option value="bmw">BMW</option>
  <option value="audi">Audi</option>
</select>

gets replaced with
<select id="neighborhood">
<% do until rsNeighborhood.eof%>
<select name="tNhood" ID="Select1"><option value="" selected>Select Neighborhood</option><%=sHTNH%></select>
<%
rsNeighborhood.movenext
loop
%>
</select>


<select id="community">
<option value="">Select A Community</option>
<% do until rsCommunity.eof%>
 <option value="<%=communityID%>"><%=communityName%></option>
<%
rsCommunity.movenext
loop
%>
</select>

<select id="lot">
<%do until rsLots.eof%>
<option value="<%=someID%>" class="<%=communityName%>"><%=lotName%></option>
<%
rsLots.movenext
loop
%>
</select>

Then at the top of the page link to jquery  http://ajax.googleapis.com/ajax/libs/jquery/1.6.3/jquery.min.js  more info on this here  http://docs.jquery.com/Downloading_jQuery

and use this code
$("#community").chained("#lot");

I am assuming your lot recordset will have the field to include the community name.  So you will probably have to load this from a view.
0
Fill in the form and get your FREE NFR key NOW!

Veeam® is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

 
LVL 54

Expert Comment

by:Scott Fell, EE MVE
ID: 36497432
sorry... forget


<select id="neighborhood">
<% do until rsNeighborhood.eof%>
<select name="tNhood" ID="Select1"><option value="" selected>Select Neighborhood</option><%=sHTNH%></select>
<%
rsNeighborhood.movenext
loop
%>
</select>
0
 
LVL 82

Expert Comment

by:hielo
ID: 36497505
try:
<script type="text/javascript">
function fetchItems(val){
	this.form.onsubmit=function(){return true};
	//this is so you know if the for was the result of an "onchange"
	//Or if the user clicked submit
	document.getElementById("formCompleted").value=0;
	this.submit();
}
</script>
<form action="websiteupdate_send.asp" METHOD="POST" name="frmData" onsubmit="return verifyData(this)">
<table border="0">
      <%      
	  		Dim rs
            Dim rt
            Dim sNhood
            Dim sLots
            Dim sRegion
            Dim sSQL
            Dim MyConn
            Dim sHTML
            Dim sHTNH
            Dim sHTL 
            Dim NTLogin, sSender, sSentDate, sText
            NTLogin = Request.ServerVariables("AUTH_USER")
            if Left(NTLogin,7) = "JWHOMES" then
                  sSender = Right(NTLogin, len(NTLogin)-8) & "@jwhomes.com"
            else
                  sSender = NTLogin & "@jwhomes.com"
            end if
            Set oJWI = Server.CreateObject("JWIntranet.clsJWIntranet")
      
            sNhood = "select distinct neighborhoodname from homelinkii..neighborhoods where active = 1"
                    
            
            
            Set rt = oJWI.RunSQLReturnRS(sNhood)
			
            Do while not rt.eof
                  sHTNH = sHTNH & "<option value='" & rt("neighborhoodname") & "'"
                  sHTNH = sHTNH & ">" & rt("neighborhoodname") & "</option>"
                  rt.movenext
            Loop      
            
            Set rt = oJWI.RunSQLReturnRS(sLots)
            Do while not rt.eof
                  sHTL = sHTL & "<option value='" & rt("lotnumber") & "'"
                  sHTL = sHTL & ">" & rt("lotnumber") & "</option>"
                  rt.movenext
            Loop      

            
            %>

      
      <%
            set rs = nothing
            
            %>
      <tr><td height=25></td></tr>
            <tr>
            <td align="right">Neighborhood:</td>
            <td><input type="hidden" id="formCompleted" name="formCompleted" value="1" /><select name="tNhood" ID="Select1" onchange="fetchItems(this);"><option value="" selected>Select Neighborhood</option><%=sHTNH%></select></td>
      </tr>
            <% 
			sHTL=""
			If "" <> Request.Form("tNhood") AND "1"<>CStr(Request.Form("formCompleted")) Then
			
				sLots = "select lotnumber from homelinkii..lots l join homelinkii..neighborhoods n on l.neighborhoodid = n.neighborhoodid where neighborhoodname = " & Request.Form("tNhood") 
                Set rt = oJWI.RunSQLReturnRS(sLots)
            	Do while not rt.eof
                  sHTL = sHTL & "<option value='" & rt("lotnumber") & "'"
                  sHTL = sHTL & ">" & rt("lotnumber") & "</option>"
                  rt.movenext
            	Loop
			End If
	      %>

            <tr>
            <td align="right">Lot:</td>
            <td><select name="tlot" ID="Select1"><option value="" selected>Select Lot</option><%=sHTL%></select></td>
      </tr>

Open in new window

0
 
LVL 54

Expert Comment

by:Scott Fell, EE MVE
ID: 36497629
I would also add where you have

do until rs.eof

Check for the recordset being empty

if not rs.eof or not rs.bof then
  do until rs.eof
 <select>...... </select>
  rs.movenext
  loop
end if
0
 

Author Comment

by:JWHomes
ID: 36498155
OK, what I have seems to almost be there.  the first drop down shows community name then the second shows up but does not list out the lot numbers like it is supposed to.  It will only say "Select Lot" no matter what neighborhood name is selected.

<form action="websiteupdate_send.asp" METHOD="POST" name="frmData" onsubmit="return verifyData(this)">
<table border="0">
      <%      Dim rs
            Dim rt
            Dim sNhood
            Dim sLots
            Dim sRegion
            Dim sSQL
            Dim MyConn
            Dim sHTML
            Dim sHTNH
            Dim sHTL
            Dim NTLogin, sSender, sSentDate, sText
            NTLogin = Request.ServerVariables("AUTH_USER")
            if Left(NTLogin,7) = "JWHOMES" then
                  sSender = Right(NTLogin, len(NTLogin)-8) & "@jwhomes.com"
            else
                  sSender = NTLogin & "@jwhomes.com"
            end if
            Set oJWI = Server.CreateObject("JWIntranet.clsJWIntranet")
      
            
            sNhood = "select distinct neighborhoodname from homelinkii..neighborhoods where active = 1"
                    
            
            
            Set rt = oJWI.RunSQLReturnRS(sNhood)
            Do while not rt.eof
                  sHTNH = sHTNH & "<option value='" & rt("neighborhoodname") & "'"
                  sHTNH = sHTNH & ">" & rt("neighborhoodname") & "</option>"
                  rt.movenext
            Loop      
            
            
            
            %>

      
      <%
            set rs = nothing
            
            %>
      <tr><td height=25></td></tr>
            <tr>
            <td align="right">Neighborhood:</td>
      <td><select name="tNhood" ID="Select1"><option value="" selected>Select Neighborhood</option><%=sHTNH%></select></td>
</tr>


            <% sHTL=""
             If "" <> Request.Form("tNhood") AND "1"<>CStr(Request.Form("formCompleted"))  Then
            sLots = "select lotnumber from homelinkii..lots l join homelinkii..neighborhoods n on l.neighborhoodid = n.neighborhoodid where neighborhoodname = " & Request.Form("tNhood")
            Set rt = oJWI.RunSQLReturnRS(sLots)
            Do while not rt.eof
            sHTL = sHTL & "<option value='" & rt("lotnumber") & "'"
            sHTL = sHTL & ">" & rt("lotnumber") & "</option>"
            rt.movenext
            Loop
                  End If
            %>


            <tr>
            <td align="right">Lot:</td>
            <td><select name="tlot" ID="Select1"><option value="" selected>Select Lot</option><%=sHTL%></select></td>
      </tr>
0
 
LVL 82

Expert Comment

by:hielo
ID: 36498271
For this to work:
 If "" <> Request.Form("tNhood") AND "1"<>CStr(Request.Form("formCompleted")) Then

You need to have:
<input type="hidden" id="formCompleted" name="formCompleted" value="1" />

and the value on that hidden field need to be changed dynamically so that you know when the submitted request is just to populate the second list.  That is what lines 1-9 of my post do. When the user actually intends to submit the form (as in when the user completes the form and then clicks submit), then Request.Form("formCompleted") will give you 1. Otherwise if the form was submitted just to generate/populate that other dropdown, then  Request.Form("formCompleted") will have 0

So put lines 1-9 at the top of your page AND also COPY and PASTE line 62 of MY post intead of your equivalent line. You also need the onchange on the first select.
0
 

Author Comment

by:JWHomes
ID: 36498707
Ok cool... I have put those suggestions into place.  It doesn't error out but the second drop down does not seem to be updating, it never pulls any actual data

<script type="text/javascript">
 function fetchItems(val){
this.form.onsubmit=function(){return true};
//this is so you know if the for was the result of an "onchange"
//Or if the user clicked submit document.getElementById("formCompleted").value=0;
 this.submit();
}
</script>

<form action="websiteupdate_send.asp" METHOD="POST" name="frmData" onsubmit="return verifyData(this)">
<table border="0">
      <%      Dim rs
            Dim rt
            Dim sNhood
            Dim sLots
            Dim sRegion
            Dim sSQL
            Dim MyConn
            Dim sHTML
            Dim sHTNH
            Dim sHTL
            Dim NTLogin, sSender, sSentDate, sText
            NTLogin = Request.ServerVariables("AUTH_USER")
            if Left(NTLogin,7) = "JWHOMES" then
                  sSender = Right(NTLogin, len(NTLogin)-8) & "@jwhomes.com"
            else
                  sSender = NTLogin & "@jwhomes.com"
            end if
            Set oJWI = Server.CreateObject("JWIntranet.clsJWIntranet")
            //sSQL = "select sPlan_Name from BuilderSuite..Plans where sPlan_Name not like 'XX%' order by sPlan_Name"
            
            sNhood = "select distinct neighborhoodname from homelinkii..neighborhoods where active = 1"
                    
            
            
            Set rt = oJWI.RunSQLReturnRS(sNhood)
            Do while not rt.eof
                  sHTNH = sHTNH & "<option value='" & rt("neighborhoodname") & "'"
                  sHTNH = sHTNH & ">" & rt("neighborhoodname") & "</option>"
                  rt.movenext
            Loop      
            
            
            
            %>

      
      <%
            set rs = nothing
            
            %>
      <tr><td height=25></td></tr>
            <tr>
            <td align="right">Neighborhood:</td>
      <td><input type="hidden" id="formCompleted" name="formCompleted" value="1" /><select name="tNhood" ID="Select1" onchange="fetchItems(this);"><option value="" selected>Select Neighborhood</option><%=sHTNH%></select></td>

</tr>


            <% sHTL=""
             If "" <> Request.Form("tNhood") AND "1"<>CStr(Request.Form("formCompleted"))  Then
            sLots = "select lotnumber from homelinkii..lots l join homelinkii..neighborhoods n on l.neighborhoodid = n.neighborhoodid where neighborhoodname = " & Request.Form("tNhood")
            Set rt = oJWI.RunSQLReturnRS(sLots)
            Do while not rt.eof
            sHTL = sHTL & "<option value='" & rt("lotnumber") & "'"
            sHTL = sHTL & ">" & rt("lotnumber") & "</option>"
            rt.movenext
            Loop
                  End If
            %>


            <tr>
            <td align="right">Lot:</td>
            <td><select name="tlot" ID="Select1"><option value="" selected>Select Lot</option><%=sHTL%></select></td>
      </tr>
0
 
LVL 82

Expert Comment

by:hielo
ID: 36498727
Replace the previous script with the following:
<script type="text/javascript">
 function fetchItems(sel){ 
sel.form.onsubmit=function(){return true}; 
//this is so you know if the for was the result of an "onchange" 
//Or if the user clicked submit document.getElementById("formCompleted").value=0;
 sel.submit(); 
} 
</script>

Open in new window

0
 

Author Comment

by:JWHomes
ID: 36498769
Still getting the same results, ideally this would lead me to ask...  This is going to be the beginning of a set of cascading drop downs where each ones selection will feed the data to the next  Trying to parse out only valid selections so that when the final submit button is hit, all this data will be inserted into a SQL table.  The user will be probably changing their selections on the drop downs some based on the answers given so each time a drop down is changed would need to re-query the data.  It still stands where the lots drop down only shows "Select Lot"
0
 
LVL 82

Expert Comment

by:hielo
ID: 36498915
>> ...  where neighborhoodname = " & Request.Form("tNhood")
Is neighborhoodname a "text" field (as opposed to a numeric field)? IF so, then try enclosing the value in apostrophes. Also, check to see if you get any results immediately after the query is executed (copy and paste the segment of code below):

...
 <% sHTL=""
        If "" <> Request.Form("tNhood") AND "1"<>CStr(Request.Form("formCompleted"))  Then 
            sLots = "select lotnumber from homelinkii..lots l join homelinkii..neighborhoods n on l.neighborhoodid = n.neighborhoodid where neighborhoodname = '" & Request.Form("tNhood") & "'"
            Set rt = oJWI.RunSQLReturnRS(sLots) 
              If rt.EOF Then
                Response.Write( "No results found for " & Server.HTMLEncode(sLots) )
              Else
                Do while not rt.eof 
                 sHTL = sHTL & "<option value='" & Server.HTMLEncode( rt("lotnumber").value) & "'" 
                 sHTL = sHTL & ">" & Server.HTMLEncode( rt("lotnumber").value ) & "</option>" 
                 rt.movenext 
                Loop 
             End If 
        End If

            %> 
...

Open in new window

0
 
LVL 82

Expert Comment

by:hielo
ID: 36499289
Also, try changing:
If "" <> Request.Form("tNhood") AND...

to:
If "" <> CStr(Request.Form("tNhood")) AND...
0
 

Author Comment

by:JWHomes
ID: 36499474
Thanks for your patience, I am yielding the same results.  It is as though the second drop down doesnt even try to query when the neighborhood is selected.  It is in fact a text field passing in a name.  Here is the code updated with your changes

<script type="text/javascript">
 function fetchItems(sel){
sel.form.onsubmit=function(){return true};
//this is so you know if the for was the result of an "onchange"
//Or if the user clicked submit document.getElementById("formCompleted").value=0;
 sel.submit();
}
</script>


<form action="websiteupdate_send.asp" METHOD="POST" name="frmData" onsubmit="return verifyData(this)">
<table border="0">
      <%      Dim rs
            Dim rt
            Dim sNhood
            Dim sLots
            Dim sRegion
            Dim sSQL
            Dim MyConn
            Dim sHTML
            Dim sHTNH
            Dim sHTL
            Dim NTLogin, sSender, sSentDate, sText
            NTLogin = Request.ServerVariables("AUTH_USER")
            if Left(NTLogin,7) = "JWHOMES" then
                  sSender = Right(NTLogin, len(NTLogin)-8) & "@jwhomes.com"
            else
                  sSender = NTLogin & "@jwhomes.com"
            end if
            Set oJWI = Server.CreateObject("JWIntranet.clsJWIntranet")
            //sSQL = "select sPlan_Name from BuilderSuite..Plans where sPlan_Name not like 'XX%' order by sPlan_Name"
            
            sNhood = "select distinct neighborhoodname from homelinkii..neighborhoods where active = 1"
                    
            
            
            Set rt = oJWI.RunSQLReturnRS(sNhood)
            Do while not rt.eof
                  sHTNH = sHTNH & "<option value='" & rt("neighborhoodname") & "'"
                  sHTNH = sHTNH & ">" & rt("neighborhoodname") & "</option>"
                  rt.movenext
            Loop      
            
            
            
            %>

      
      <%
            set rs = nothing
            
            %>
      <tr><td height=25></td></tr>
            <tr>
            <td align="right">Neighborhood:</td>
      <td><input type="hidden" id="formCompleted" name="formCompleted" value="1" /><select name="tNhood" ID="Select1" onchange="fetchItems(this);"><option value="" selected>Select Neighborhood</option><%=sHTNH%></select></td>

</tr>


            <% sHTL=""
If "" <> CStr("tNhood") AND "1"<>CStr(Request.Form("formCompleted")) Then
 sLots = "select lotnumber from homelinkii..lots l join homelinkii..neighborhoods n on l.neighborhoodid = n.neighborhoodid where neighborhoodname = '" & Request.Form("tNhood") & "'"
      Set rt = oJWI.RunSQLReturnRS(sLots)
If rt.EOF Then
Response.Write( "No results found for " & Server.HTMLEncode(sLots) )
Else
Do while not rt.eof
sHTL = sHTL & "<option value='" & Server.HTMLEncode( rt("lotnumber").value) & "'"
sHTL = sHTL & ">" & Server.HTMLEncode( rt("lotnumber").value ) & "</option>"
rt.movenext
 Loop
 End If
 End If
 %>



            <tr>
            <td align="right">Lot:</td>
            <td><select name="tlot" ID="Select1"><option value="" selected>Select Lot</option><%=sHTL%></select></td>
      </tr>

0
 
LVL 82

Expert Comment

by:hielo
ID: 36499495
line 6 of my FIRST post (ID:36497505) should NOT be commented out. It needs to be on a line by itself
<script type="text/javascript">
 function fetchItems(sel){ 
sel.form.onsubmit=function(){return true}; 

//this is so you know if the for was the result of an "onchange" 
//Or if the user clicked submit 

document.getElementById("formCompleted").value=0;

 sel.submit(); 
} 
</script>

Open in new window

0
 

Author Comment

by:JWHomes
ID: 36499504
Got it.  Moved down a line and tested with same results.
0
 
LVL 82

Expert Comment

by:hielo
ID: 36499554
What is this?
If "" <> CStr("tNhood")

Read ID:36499289 again - CAREFULLY!!!
0
 

Author Comment

by:JWHomes
ID: 36502075
Little too quick on the reply, I totally missed that.  Thanks for pointing that out.  I have made the update but unfortunatly still yielding the same reults.


<script type="text/javascript">
 function fetchItems(sel){
sel.form.onsubmit=function(){return true};
//this is so you know if the for was the result of an "onchange"
//Or if the user clicked submit
document.getElementById("formCompleted").value=0;
 sel.submit();
}
</script>


<form action="websiteupdate_send.asp" METHOD="POST" name="frmData" onsubmit="return verifyData(this)">
<table border="0">
      <%      Dim rs
            Dim rt
            Dim sNhood
            Dim sLots
            Dim sRegion
            Dim sSQL
            Dim MyConn
            Dim sHTML
            Dim sHTNH
            Dim sHTL
            Dim NTLogin, sSender, sSentDate, sText
            NTLogin = Request.ServerVariables("AUTH_USER")
            if Left(NTLogin,7) = "JWHOMES" then
                  sSender = Right(NTLogin, len(NTLogin)-8) & "@jwhomes.com"
            else
                  sSender = NTLogin & "@jwhomes.com"
            end if
            Set oJWI = Server.CreateObject("JWIntranet.clsJWIntranet")
            //sSQL = "select sPlan_Name from BuilderSuite..Plans where sPlan_Name not like 'XX%' order by sPlan_Name"
            
            sNhood = "select distinct neighborhoodname from homelinkii..neighborhoods where active = 1"
                    
            
            
            Set rt = oJWI.RunSQLReturnRS(sNhood)
            Do while not rt.eof
                  sHTNH = sHTNH & "<option value='" & rt("neighborhoodname") & "'"
                  sHTNH = sHTNH & ">" & rt("neighborhoodname") & "</option>"
                  rt.movenext
            Loop      
            
            
            
            %>

      
      <%
            set rs = nothing
            
            %>
      <tr><td height=25></td></tr>
            <tr>
            <td align="right">Neighborhood:</td>
      <td><input type="hidden" id="formCompleted" name="formCompleted" value="1" /><select name="tNhood" ID="Select1" onchange="fetchItems(this);"><option value="" selected>Select Neighborhood</option><%=sHTNH%></select></td>

</tr>


            <% sHTL=""
If "" <> CStr(Request.Form("tNhood")) AND "1"<>CStr(Request.Form("formCompleted")) Then
 sLots = "select lotnumber from homelinkii..lots l join homelinkii..neighborhoods n on l.neighborhoodid = n.neighborhoodid where neighborhoodname = '" & Request.Form("tNhood") & "'"
      Set rt = oJWI.RunSQLReturnRS(sLots)
If rt.EOF Then
Response.Write( "No results found for " & Server.HTMLEncode(sLots) )
Else
Do while not rt.eof
sHTL = sHTL & "<option value='" & Server.HTMLEncode( rt("lotnumber").value) & "'"
sHTL = sHTL & ">" & Server.HTMLEncode( rt("lotnumber").value ) & "</option>"
rt.movenext
 Loop
 End If
 End If
 %>



            <tr>
            <td align="right">Lot:</td>
            <td><select name="tlot" ID="Select1"><option value="" selected>Select Lot</option><%=sHTL%></select></td>
      </tr>
0
 
LVL 82

Expert Comment

by:hielo
ID: 36502390
the code above is for a page that is supposed to submit to itself. Is the code above saved in "websiteupdate_send.asp" (since that is where you have your <form action=...>)?  If these are different pages, then you will need to dynamically adjust the action:
<script type="text/javascript">
 function fetchItems(sel){ 
sel.form.action="<%=Request.ServerVariables("SCRIPT_NAME")%>";
sel.form.onsubmit=function(){return true}; 
//this is so you know if the for was the result of an "onchange" 
//Or if the user clicked submit 
document.getElementById("formCompleted").value=0;
 sel.submit(); 
} 
</script>

Open in new window

0
 

Author Comment

by:JWHomes
ID: 36502436
Sorry, yes... the page will need to refresh upon changing the drop down and will call the websiteupdate ONLY when the Submit is processed ONLY to push to SQL and create a response email.  That page will handle those two items.  This current page will need what I can only describe without better knowlege to be a postback or something to run the second query/dropdown after the first is selected.  I added the changes to to script you provided (Thanks again) but still is not showing anything in the second dropdown.  
0
 
LVL 82

Expert Comment

by:hielo
ID: 36502503
OK, so just to be sure, you are working on "page1.asp", and when posted, it will send/submit the data to "websiteupdate_send.asp", correct?

All the code I've given you so far was meant for "page1.asp".  Do you by any chance have:
<input name="submit"..>
OR
<input type="submit" id="submit"..>
OR:

<input type="submit" name="submit" id="submit"..>

(where "submit" is all in lowercase for either the name and/or the id attributes? IF so, try changing it to upper case "S":

<input type="submit" name="Submit" id="Submit" >
0
 

Author Comment

by:JWHomes
ID: 36502585
I do have two buttons, a reset and submit to transmit the chosen data to page2 (websiteupdate).  This is the page1.asp page but before the user gets to the submit button I wanted the drop downs to be parsed down actively so that when the submit button was hit the user would be done on the page.  Here is the submit info I currently have -

<input type="submit" value="Submit" name="submit">
            <input type="reset" value="Reset" name="reset">
I canged the name and added ID but I really only want the user to interract with the Submit button once he/she is done with all the drop downs
0
 
LVL 82

Expert Comment

by:hielo
ID: 36502825
>>but I really only want the user to interract with the Submit button once he/she is done with all the drop downs
I understand, but my suggestions would NOT interfere with how the user is interacting with the page.

You should NEVER use name="submit" and/or id="submit" on ANY form element.  Otherwise it will create a conflict with the javascript "submit()" form method.

Which brings me to another point. On the code latest js code:
 sel.submit();

should really be:
 sel.form.submit();


BUT you also HAVE to change this:
<input type="submit" value="Submit" name="submit">

to this:
<input type="submit" value="Submit" name="Submit">

otherwise the submit() method of the form object will be "clobbered".
0
 
LVL 82

Expert Comment

by:hielo
ID: 36502829
Here it is again:
<script type="text/javascript">
 function fetchItems(sel){ 
sel.form.action="<%=Request.ServerVariables("SCRIPT_NAME")%>";
sel.form.onsubmit=function(){return true}; 
//this is so you know if the for was the result of an "onchange" 
//Or if the user clicked submit 
document.getElementById("formCompleted").value=0;
 sel.form.submit(); 
} 
</script>

Open in new window

0
 

Author Comment

by:JWHomes
ID: 36502896
THAT WORKS!!!  Thank you SO much, I really appreciate it.  One final question and I am good to go and can finish this project out once and for all.  After the neighborhood is selected it does populate the lots drop down with the appropriate items.  The neighborhood drop down no longer displays the neighborhood name selected after the page refreshes.  Is that something that could reasily be altered?
0
 
LVL 82

Accepted Solution

by:
hielo earned 2000 total points
ID: 36502953
>>The neighborhood drop down no longer displays the neighborhood name selected after the page refreshes
Instead of:
Set rt = oJWI.RunSQLReturnRS(sNhood)
            Do while not rt.eof
                  sHTNH = sHTNH & "<option value='" & rt("neighborhoodname") & "'"
                  sHTNH = sHTNH & ">" & rt("neighborhoodname") & "</option>"
                  rt.movenext
            Loop

Try:
Set rt = oJWI.RunSQLReturnRS(sNhood)
            Do while not rt.eof
                  sHTNH = sHTNH & "<option value='" & Server.HTMLEncode(rt("neighborhoodname").value) & "'"
                  If Trim(CStr(Request.Form("tNhood"))) = Trim(CStr(rt("neighborhoodname").value)) Then
                        sHTNH = sHTNH & " selected='selected' "
                  End If
                  sHTNH = sHTNH & ">" & Server.HTMLEncode(rt("neighborhoodname").value) & "</option>"
                  rt.movenext
            Loop

Open in new window

0
 

Author Closing Comment

by:JWHomes
ID: 36503008
Thank you so much!!!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

636 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