Solved

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

Posted on 2011-09-07
27
331 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
  • 12
  • 11
  • 4
27 Comments
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
Comment Utility
0
 

Author Comment

by:JWHomes
Comment Utility
I really need to use SQL to dynamically populate the drop downs as the values will constantly be changing
0
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
Comment Utility
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
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
Comment Utility
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
Comment Utility
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 52

Expert Comment

by:Scott Fell, EE MVE
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
>> ...  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
Comment Utility
Also, try changing:
If "" <> Request.Form("tNhood") AND...

to:
If "" <> CStr(Request.Form("tNhood")) AND...
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

Author Comment

by:JWHomes
Comment Utility
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
Comment Utility
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
Comment Utility
Got it.  Moved down a line and tested with same results.
0
 
LVL 82

Expert Comment

by:hielo
Comment Utility
What is this?
If "" <> CStr("tNhood")

Read ID:36499289 again - CAREFULLY!!!
0
 

Author Comment

by:JWHomes
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
>>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
Comment Utility
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
Comment Utility
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 500 total points
Comment Utility
>>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
Comment Utility
Thank you so much!!!
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
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.

771 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now