Jump to content

java+asp+select+menu


Recommended Posts

HEllo,I have a problem! I am using an example of selecting from DB with select box , what i would like to do is that i would change an view of selectbox with some modfied java menu. U need to know that slect is not an option or option group , but it works directly from DB and by changing an slectbox you create an filter of selection, the example is from w3school. The problem is , how to change or modify the select function with java or something else to get view you would like ( the problem is because i would like to hide borders of selectbox , but this is not possible not with css and IE ).Slect code , that work prfectly:<html><body><%set conn=Server.CreateObject("ADODB.Connection")conn.Provider="Microsoft.Jet.OLEDB.4.0"conn.Open(Server.Mappath("/db/northwind.mdb"))set rs=Server.CreateObject("ADODB.recordset")sql="SELECT DISTINCT Country FROM Customers ORDER BY Country"rs.Open sql,conncountry=request.form("country")%><form method="post">Choose Country <select name="country"><% do until rs.EOF response.write("<option") if rs.fields("country")=country then response.write(" selected") end if response.write(">") response.write(rs.fields("Country")) rs.MoveNextlooprs.Closeset rs=Nothing %></select><input type="submit" value="Show customers"></form><%if country<>"" then sql="SELECT Companyname,Contactname,Country FROM Customers WHERE country='" & country & "'" set rs=Server.CreateObject("ADODB.Recordset") rs.Open sql,conn%> <table width="100%" cellspacing="0" cellpadding="2" border="1"> <tr> <th>Companyname</th> <th>Contactname</th> <th>Country</th> </tr><%do until rs.EOF response.write("<tr>") response.write("<td>" & rs.fields("companyname") & "</td>") response.write("<td>" & rs.fields("contactname") & "</td>") response.write("<td>" & rs.fields("country") & "</td>") response.write("</tr>") rs.MoveNextlooprs.closeconn.Closeset rs=Nothingset conn=Nothing%></table><% end if %></body></html>and JAVA that i would like to use: can you give me an exampleThank you

Link to post
Share on other sites

If i understand you correctly you may wish to try the following. It's not perfect but it's not far off:

<script language="javascript">	showVar=null;	function showHide(){  if(document.getElementById('mySelectBox').style.visibility=="hidden"){ 	 document.getElementById('mySelectBox').style.visibility='visible';  }else{ 	 document.getElementById('mySelectBox').style.visibility='hidden';  }	}		function hideSelect(){  //setTimeout("document.getElementById('mySelectBox').style.visibility='hidden'",100)	}  function move_up() {    //scroll_clipper.scrollTop = 0;  }</script><body><form name="myForm"><div style="position: absolute;  z-index: 1" id="layer1"><div style="position: absolute;  z-index: 1; left:-1px; top:24px; visibility:hidden" id="mySelectBox">   <div id='scroll_clipper' style='filter:alpha(opacity=80);position:absolute; width:150px; height: 100px; overflow-y:auto'>    <div id='scroll_text' style="background-color:#00FF00;">	<table border="0" cellspacing=0 cellpadding=0 width="100%" id="table1"><%For s=1 to 100%>  <tr onclick="document.myForm.mySelect.value=<%=s%>;move_up();showHide();" style="cursor:pointer;" color="#FFFFFF" onmouseout="this.bgColor='';this.style.color = '';" onmouseover="this.bgColor='#FF0000';this.style.color = '#ffffff';"> 	 <td><%=s%></td>  </tr><%Next%>	</table>     </div>  </div></div><input type="text" name="mySelect" value="" readonly onclick="this.select();showHide();" onblur="hideSelect();" style="cursor:pointer;" /></div></div></div><br /><br /><input type=submit></form></body></html>

Do something like this this for yours:

<script language="javascript">   showVar=null;   function showHide(){      if(document.getElementById('mySelectBox').style.visibility=="hidden"){            document.getElementById('mySelectBox').style.visibility='visible';      }else{            document.getElementById('mySelectBox').style.visibility='hidden';         }   }	   function hideSelect(){      //setTimeout("document.getElementById('mySelectBox').style.visibility='hidden'",100)   }   function move_up() {      //scroll_clipper.scrollTop = 0;   }</script><body><form name="myForm"><div style="position: absolute;  z-index: 1" id="layer1"><div style="position: absolute;  z-index: 1; left:-1px; top:24px; visibility:hidden" id="mySelectBox">   <div id='scroll_clipper' style='filter:alpha(opacity=80);position:absolute; width:150px; height: 100px; overflow-y:auto'>      <div id='scroll_text' style="background-color:#00FF00;">         <table border="0" cellspacing=0 cellpadding=0 width="100%" id="table1"><%'------------------------------'DSN'------------------------------   set conn=server.createobject("ADODB.CONNECTION")      conn.Provider="Microsoft.Jet.OLEDB.4.0"      conn.Open(Server.Mappath("/db/northwind.mdb"))'------------------------------'Get data..'------------------------------   set rs = conn.execute("SELECT DISTINCT Country FROM Customers ORDER BY Country")        while not rs.eof      thisCountry = trim(rs(0))      %>            <tr onclick="document.myForm.mySelect.value=<%=thisCountry%>;move_up();showHide();" style="cursor:pointer;" color="#FFFFFF" onmouseout="this.bgColor='';this.style.color = '';" onmouseover="this.bgColor='#FF0000';this.style.color = '#ffffff';">               <td><%=thisCountry%></td>            </tr>            <%rs.movenext      wEnd'------------------------------'Close conn..'------------------------------      rs.close   set rs = nothing      conn.close   set conn = nothing%>         </table>       </div>   </div></div><input type="text" name="country" value="" readonly onclick="this.select();showHide();" onblur="hideSelect();" style="cursor:pointer;" /></div></div><br /><br /><input type=submit value="Show Customers" /></form></body></html>

It still needs a function that's going to kill the focus if the user clicks away from the select list. Time permitting I will post it if I get the chance unless someone out there can help in the meantime.CheersVin

Link to post
Share on other sites

Hello!!!Thank you for this code. But still i have a problem with selection, because, when i would like to make an selection, there is an error , if i check the error in an IE it is written something like this: document.myForm.mySelect.value an object is null or not an objectDo u know what is wrong?Thanks againK

Link to post
Share on other sites

Hi,yes, that was my mistake for changing the name of the text-box to 'country' following your code.Can you try this and see if this works:

<script language="javascript">  showVar=null;  function showHide(){     if(document.getElementById('mySelectBox').style.visibility=="hidden"){           document.getElementById('mySelectBox').style.visibility='visible';     }else{           document.getElementById('mySelectBox').style.visibility='hidden';        }  }  function hideSelect(){     //setTimeout("document.getElementById('mySelectBox').style.visibility='hidden'",100)  }  function move_up() {     //scroll_clipper.scrollTop = 0;  }</script><body><form name="myForm"><div style="position: absolute;  z-index: 1" id="layer1"><div style="position: absolute;  z-index: 1; left:-1px; top:24px; visibility:hidden" id="mySelectBox">  <div id='scroll_clipper' style='filter:alpha(opacity=80);position:absolute; width:150px; height: 100px; overflow-y:auto'>     <div id='scroll_text' style="background-color:#00FF00;">        <table border="0" cellspacing=0 cellpadding=0 width="100%" id="table1"><%'------------------------------'DSN'------------------------------  set conn=server.createobject("ADODB.CONNECTION")     conn.Provider="Microsoft.Jet.OLEDB.4.0"     conn.Open(Server.Mappath("/db/northwind.mdb"))'------------------------------'Get data..'------------------------------  set rs = conn.execute("SELECT DISTINCT Country FROM Customers ORDER BY Country")       while not rs.eof     thisCountry = trim(rs(0))     %>           <tr onclick="document.myForm.country.value=<%=thisCountry%>;move_up();showHide();" style="cursor:pointer;" color="#FFFFFF" onmouseout="this.bgColor='';this.style.color = '';" onmouseover="this.bgColor='#FF0000';this.style.color = '#ffffff';">              <td><%=thisCountry%></td>           </tr>           <%rs.movenext     wEnd'------------------------------'Close conn..'------------------------------     rs.close  set rs = nothing     conn.close  set conn = nothing%>        </table>      </div>  </div></div><input type="text" name="country" value="" readonly onclick="this.select();showHide();" onblur="hideSelect();" style="cursor:pointer;" /></div></div><br /><br /><input type=submit value="Show Customers" /></form></body></html>

Link to post
Share on other sites

Hi Vin,A new error acured , when you click on one of the selections in box, IE writes for example: ´country1´ is undefinedis me that did something wrong or,... because , the only thing that i did was, that i created the same db and document.asp file with this code.hmmm :)

Link to post
Share on other sites
Can you paste your code and the error message in it's entirety so I can have a look.CheersVin

Vin,My code is only the copy of your copy from last post. When i pres on a textbox , the drop down accures , after i press on one of the selections , nothing happens, but down on the lef side , an yellow logo that represent an error of a script shows ( as part of IE ) , when i look at it , there is an arror that tells that the chosen selection us undefined. Should i do someting more with this code? Because i am only a beginer in asp and java , when i look at this code , i looks like something is missing, the part which would export data in tables. I tried to combine your code with my example at first post, but no luck :) And something else:When i select from dropdown , the selection is not written in to text box. Only when i select the first value , works, but when i press button ther is no data shown.Thanks
Link to post
Share on other sites

I think it may have been the values:<tr onclick="document.myForm.country.value='<%=thisCountry%>';There were no quotes around them before.If you copy the following and save it as an asp page it should work.Can you try this and see if it works at your end:

<%Dim testArray(50)	for i = 0 to 50  testArray(i)="Test country "&i	next%><script language="javascript">  showVar=null;  function showHide(){     if(document.getElementById('mySelectBox').style.visibility=="hidden"){           document.getElementById('mySelectBox').style.visibility='visible';     }else{           document.getElementById('mySelectBox').style.visibility='hidden';        }  }  function hideSelect(){     //setTimeout("document.getElementById('mySelectBox').style.visibility='hidden'",100)  }  function move_up() {     //scroll_clipper.scrollTop = 0;  }</script><body><form name="myForm"><div style="position: absolute;  z-index: 1" id="layer1"><div style="position: absolute;  z-index: 1; left:-1px; top:24px; visibility:hidden" id="mySelectBox">  <div id='scroll_clipper' style='filter:alpha(opacity=80);position:absolute; width:150px; height: 100px; overflow-y:auto'>     <div id='scroll_text' style="background-color:#00FF00;">        <table border="0" cellspacing=0 cellpadding=0 width="100%" id="table1">  <%  For i=0 to ubound(testArray)  thisCountry = testArray(i)       %>           <tr onclick="document.myForm.country.value='<%=thisCountry%>';move_up();showHide();" style="cursor:pointer;" color="#FFFFFF" onmouseout="this.bgColor='';this.style.color = '';" onmouseover="this.bgColor='#FF0000';this.style.color = '#ffffff';">              <td><%=thisCountry%></td>           </tr>           <%next%>        </table>      </div>  </div></div><input type="text" name="country" value="" readonly onclick="this.select();showHide();" onblur="hideSelect();" style="cursor:pointer;" /></div></div><br /><br /><input type=submit value="Show Customers" /></form></body></html>

CheersVin

Link to post
Share on other sites

Hi Vin,Yes the problem was in quotes,... , now the code works fine. Im trying to get results of the selected value, so i did it like this, but the problem is that when i press button no results ,hmm... This is my code now , the last part i put so i could get results from the first part, but there is no result?, eaven that your code gives me in address the result like this: http://localhost:90/document.asp?country=country1P.S. Two more questions, what i would need to change that the drop down box would look ###### select box as menu , and when i would click on the value , there i wouldn t need any button ?Thanksmy code:<html><script language="javascript"> showVar=null; function showHide(){ if(document.getElementById('mySelectBox').style.visibility=="hidden"){ document.getElementById('mySelectBox').style.visibility='visible'; }else{ document.getElementById('mySelectBox').style.visibility='hidden'; } } function hideSelect(){ //setTimeout("document.getElementById('mySelectBox').style.visibility='hidden'",100) } function move_up() { //scroll_clipper.scrollTop = 0; }</script><body><form name="myForm"><div style="position: absolute; z-index: 1" id="layer1"><div style="position: absolute; z-index: 1; left:-1px; top:24px; visibility:hidden" id="mySelectBox"> <div id='scroll_clipper' style='filter:alpha(opacity=80);position:absolute; width:150px; height: 100px; overflow-y:auto'> <div id='scroll_text' style="background-color:#00FF00;"> <table border="0" cellspacing=0 cellpadding=0 width="100%" id="table1"><%'------------------------------'DSN'------------------------------ set conn=server.createobject("ADODB.CONNECTION") conn.Provider="Microsoft.Jet.OLEDB.4.0" conn.Open(Server.Mappath("/db/northwind.mdb"))'------------------------------'Get data..'------------------------------ set rs = conn.execute("SELECT DISTINCT Country FROM Customers ORDER BY Country") while not rs.eof thisCountry = trim(rs(0)) %> <tr onclick="document.myForm.country.value='<%=thisCountry%>';move_up();showHide();" style="cursor:pointer;" color="#FFFFFF" onmouseout="this.bgColor='';this.style.color = '';" onmouseover="this.bgColor='#FF0000';this.style.color = '#ffffff';"> <td><%=thisCountry%></td> </tr> <%rs.movenext wEnd'------------------------------'Close conn..'------------------------------ rs.close set rs = nothing conn.close set conn = nothing%> </table> </div> </div></div><input type="text" name="country" value="" readonly onclick="this.select();showHide();" onblur="hideSelect();" style="cursor:pointer;" /></div></div><br /><br /><input type=submit value="Show Customers" /></form><%if country<>"" thensql="SELECT Customers FROM Customers WHERE country='" & country & "'"set rs=Server.CreateObject("ADODB.Recordset")rs.Open sql,conn%><table width="100%" cellspacing="0" cellpadding="2" border="1"><tr><th>Customers</th></tr><%do until rs.EOFresponse.write("<tr>")response.write("<td>" & rs.fields("Customers") & "</td>")response.write("</tr>")rs.MoveNextlooprs.closeconn.Closeset rs=Nothingset conn=Nothing%></table><% end if %></body></html>

Link to post
Share on other sites

Try this:

<%'------------------------------------'These Variables'------------------------------------	selectWidth = 200    'width of select box in pixels	selectHeight = 200    'height of select box in pixels	selectAlpha = 80     'transparency of drop-down list	selectBackgroundColor = "#00FF00"    'Background colour of drop down list	selectHighlightColor = "#FF0000"     'background colour of option when mouse over	selectTextHighlightColor = "#FFF"    'text colour of option when mouse over%><script language="javascript">	function showHide(){  if(document.getElementById('mySelectBox').style.visibility=="hidden"){ 	 document.getElementById('mySelectBox').style.visibility='visible';  }else{ 	 document.getElementById('mySelectBox').style.visibility='hidden';  }	} function move_up() {    //scroll_clipper.scrollTop = 0; }</script><style>	input{border:none;cursor:pointer;width:100%;padding:2;background-color:transparent;}	#customSelect{border:1px solid #c0c0c0;cursor:pointer;}</style><body bgcolor=#33CC33><form name="myForm" method=post><div style="position: absolute;  z-index: 1" id="layer1"><div style="position: absolute;  z-index: 1; left:0px; top:22px; visibility:hidden" id="mySelectBox"> <div id='scroll_clipper' style='filter:alpha(opacity=<%=selectAlpha%>);position:absolute; width:<%=selectWidth%>px; height: <%=selectHeight%>px; overflow-y:auto'>    <div id='scroll_text' style="background-color:<%=selectBackgroundColor%>;">       <table border="0" cellspacing=0 cellpadding=0 width="100%" id="table1">  <%  '------------------------------  'DSN  '------------------------------ 	 set conn=server.createobject("ADODB.CONNECTION") 	 conn.Provider="Microsoft.Jet.OLEDB.4.0" 	 conn.Open(Server.Mappath("/db/northwind.mdb"))    '------------------------------  'Get data..  '------------------------------ 	 set rs = conn.execute("SELECT DISTINCT Country FROM Customers ORDER BY Country")     while not rs.eof    thisCountry = trim(rs(0))   	 %>             <tr onclick="document.myForm.country.value='<%=thisCountry%>';move_up();showHide();myForm.submit();" style="cursor:pointer;" color="#FFFFFF" onmouseout="this.bgColor='';this.style.color = '';" onmouseover="this.bgColor='<%=selectHighlightColor%>';this.style.color='<%=selectTextHighlightColor%>';">                <td style="padding:0 0 1 2;"><%=thisCountry%></td>             </tr>   	 <%rs.movenext    wEnd  '------------------------------  'Close conn..  '------------------------------    rs.close 	 set rs = nothing    conn.close 	 set conn = nothing  %>       </table>     </div> </div></div><table border="0" cellpadding=0 cellspacing=0 width="<%=selectWidth%>" id="customSelect">	<tr onclick="myForm.country.select();showHide();">  <td width="100%"><input type="text" name="country" value="<%=trim(request("country"))%>" readonly /></td>  <td align="right">V</td>	</tr></table></div></form><%country = trim(request("country"))	if country<>"" then  sql="SELECT Customers FROM Customers WHERE country='" & country & "'"  set rs=Server.CreateObject("ADODB.Recordset")  rs.Open sql,conn 	 %> 	 <table width="100%" cellspacing="0" cellpadding="2" border="1"> 	 <tr> 	 <th>Customers</th> 	 </tr> 	 <%    do until rs.EOF   	 response.write("<tr>")   	 response.write("<td>" & rs.fields("Customers") & "</td>")   	 response.write("</tr>")    rs.MoveNext    loop 	 rs.close 	 conn.Close 	 set rs=Nothing 	 set conn=Nothing%> 	  	 </table>	<% end if %></body></html>

You're going to need to modify the aesthetics of the table to make it look like a select box. (Meantime; I’ve put a V to represent an arrow).This form now submits when the user makes a selection. When the form is submitted country is posted as a variable which the code now checks for. If country is something then your code will run to look up the customers.I don’t have any database connectivity here so I couldn’t test this since I modified it. You’ll have to let me know how you get on.CheersVin

Link to post
Share on other sites

<%'------------------------------------'These Variables'------------------------------------ selectWidth = 200 'width of select box in pixels selectHeight = 200 'height of select box in pixels selectAlpha = 80 'transparency of drop-down list selectBackgroundColor = "#00FF00" 'Background colour of drop down list selectHighlightColor = "#FF0000" 'background colour of option when mouse over selectTextHighlightColor = "#FFF" 'text colour of option when mouse over%><script language="javascript"> function showHide(){ if(document.getElementById('mySelectBox').style.visibility=="hidden"){ document.getElementById('mySelectBox').style.visibility='visible'; }else{ document.getElementById('mySelectBox').style.visibility='hidden'; } } function move_up() { //scroll_clipper.scrollTop = 0; }</script><style> input{border:none;cursor:pointer;width:100%;padding:2;background-color:transparent;} #customSelect{border:1px solid #c0c0c0;cursor:pointer;}</style><body bgcolor=#33CC33><form name="myForm" method=post><div style="position: absolute; z-index: 1" id="layer1"><div style="position: absolute; z-index: 1; left:0px; top:22px; visibility:hidden" id="mySelectBox"> <div id='scroll_clipper' style='filter:alpha(opacity=<%=selectAlpha%>);position:absolute; width:<%=selectWidth%>px; height: <%=selectHeight%>px; overflow-y:auto'> <div id='scroll_text' style="background-color:<%=selectBackgroundColor%>;"> <table border="0" cellspacing=0 cellpadding=0 width="100%" id="table1"> <% '------------------------------ 'DSN '------------------------------ set conn=server.createobject("ADODB.CONNECTION") conn.Provider="Microsoft.Jet.OLEDB.4.0" conn.Open(Server.Mappath("/db/northwind.mdb")) '------------------------------ 'Get data.. '------------------------------ set rs = conn.execute("SELECT DISTINCT Country FROM Customers ORDER BY Country") while not rs.eof thisCountry = trim(rs(0)) %> <tr onclick="document.myForm.country.value='<%=thisCountry%>';move_up();showHide();myForm.submit();" style="cursor:pointer;" color="#FFFFFF" onmouseout="this.bgColor='';this.style.color = '';" onmouseover="this.bgColor='<%=selectHighlightColor%>';this.style.color='<%=selectTextHighlightColor%>';"> <td style="padding:0 0 1 2;"><%=thisCountry%></td> </tr> <%rs.movenext wEnd '------------------------------ 'Close conn.. '------------------------------ rs.close set rs = nothing conn.close set conn = nothing %> </table> </div> </div></div><table border="0" cellpadding=0 cellspacing=0 width="<%=selectWidth%>" id="customSelect"> <tr onclick="myForm.country.select();showHide();"> <td width="100%"><input type="text" name="country" value="<%=trim(request("country"))%>" readonly /></td> <td align="right">V</td> </tr></table></div></form><%country = trim(request("country")) if country<>"" then sql="SELECT Customers FROM Customers WHERE country='" & country & "'" set rs=Server.CreateObject("ADODB.Recordset") rs.Open sql,conn %> <table width="100%" cellspacing="0" cellpadding="2" border="1"> <tr> <th>Customers</th> </tr> <% do until rs.EOF response.write("<tr>") response.write("<td>" & rs.fields("Customers") & "</td>") response.write("</tr>") rs.MoveNext loop rs.close conn.Close set rs=Nothing set conn=Nothing%> </table> <% end if %></body></html> [/code]---------------------------------------------------------------------Hello Vin,O.K. , when i make a selection an error accures in IETechnical Information (for support personnel)Error Type:ADODB.Recordset (0x800A0E7D)The connection cannot be used to perform this operation. It is either closed or invalid in this context./document.asp, line 91Browser Type:Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727) Page:POST 13 bytes to /document.aspPOST Data:country=country1I have bold the line 91, i don t have a clue what hte problem is.Sorry for bothering you with this , but i am really happy cause you are helpping me!!!Thanks,K

Link to post
Share on other sites

Yeah sorry about that, we closed the DSN conn and tried to use it again before reopening/declaring what conn was.I've moved the clean-up to the end of the script, try this one out:

<%'------------------------------------'These Variables'------------------------------------selectWidth = 200    'width of select box in pixelsselectHeight = 200    'height of select box in pixelsselectAlpha = 80     'transparency of drop-down listselectBackgroundColor = "#00FF00"    'Background colour of drop down listselectHighlightColor = "#FF0000"     'background colour of option when mouse overselectTextHighlightColor = "#FFF"    'text colour of option when mouse over%><script language="javascript">function showHide(){ if(document.getElementById('mySelectBox').style.visibility=="hidden"){  document.getElementById('mySelectBox').style.visibility='visible'; }else{  document.getElementById('mySelectBox').style.visibility='hidden'; }}function move_up() {   //scroll_clipper.scrollTop = 0;}</script><style>input{border:none;cursor:pointer;width:100%;padding:2;background-color:transparent;}#customSelect{border:1px solid #c0c0c0;cursor:pointer;}</style><body bgcolor=#33CC33><form name="myForm" method=post><div style="position: absolute;  z-index: 1" id="layer1"><div style="position: absolute;  z-index: 1; left:0px; top:22px; visibility:hidden" id="mySelectBox"><div id='scroll_clipper' style='filter:alpha(opacity=<%=selectAlpha%>);position:absolute; width:<%=selectWidth%>px; height: <%=selectHeight%>px; overflow-y:auto'>   <div id='scroll_text' style="background-color:<%=selectBackgroundColor%>;">      <table border="0" cellspacing=0 cellpadding=0 width="100%" id="table1"> <% '------------------------------ 'DSN '------------------------------  set conn=server.createobject("ADODB.CONNECTION")  conn.Provider="Microsoft.Jet.OLEDB.4.0"  conn.Open(Server.Mappath("/db/northwind.mdb"))  '------------------------------ 'Get data.. '------------------------------  set rs = conn.execute("SELECT DISTINCT Country FROM Customers ORDER BY Country")    while not rs.eof   thisCountry = trim(rs(0))    %>            <tr onclick="document.myForm.country.value='<%=thisCountry%>';move_up();showHide();myForm.submit();" style="cursor:pointer;" color="#FFFFFF" onmouseout="this.bgColor='';this.style.color = '';" onmouseover="this.bgColor='<%=selectHighlightColor%>';this.style.color='<%=selectTextHighlightColor%>';">               <td style="padding:0 0 1 2;"><%=thisCountry%></td>            </tr>    <%rs.movenext   wEnd %>      </table>    </div></div></div><table border="0" cellpadding=0 cellspacing=0 width="<%=selectWidth%>" id="customSelect"><tr onclick="myForm.country.select();showHide();"> <td width="100%"><input type="text" name="country" value="<%=trim(request("country"))%>" readonly /></td> <td align="right">V</td></tr></table></div></form><%country = trim(request("country"))if country<>"" then sql="SELECT Customers FROM Customers WHERE country='" & country & "'" set rs=Server.CreateObject("ADODB.Recordset") rs.Open sql,conn  %>  <table width="100%" cellspacing="0" cellpadding="2" border="1">  <tr>  <th>Customers</th>  </tr>  <%   do until rs.EOF    response.write("<tr>")    response.write("<td>" & rs.fields("Customers") & "</td>")    response.write("</tr>")   rs.MoveNext   loop%>    </table><% end if %><% '------------------------------ 'Close conn.. '------------------------------   rs.close  set rs = nothing   conn.close  set conn = nothing%></body></html>

Link to post
Share on other sites

Waw!!! :) It works great, now i have total control on select object :) and i can update it over the DB. Thank you for taking time,... What do u sugest me to do , so that i could use dropdown box ###### menu , I would change colors , and put open select box on one side , there is no problem with organization for me, but the problem how to change it to "open" select box with no scrollbars ,...Thanks again!K

Link to post
Share on other sites

Like this:

<%'------------------------------------'These Variables'------------------------------------selectWidth = 200    'width of select box in pixelsselectHeight = 200    'height of select box in pixelsselectAlpha = 80     'transparency of drop-down listselectBackgroundColor = "#00FF00"    'Background colour of drop down listselectHighlightColor = "#FF0000"     'background colour of option when mouse overselectTextHighlightColor = "#FFF"    'text colour of option when mouse over%><script language="javascript">	function showHide(){//  if(document.getElementById('mySelectBox').style.visibility=="hidden"){// 	 document.getElementById('mySelectBox').style.visibility='visible';//  }else{// 	 document.getElementById('mySelectBox').style.visibility='hidden';//  }	} function move_up() {// 	 scroll_clipper.scrollTop = 0; }</script><style>input{border:none;cursor:pointer;width:100%;padding:2;background-color:transparent;}#customSelect{border:1px solid #c0c0c0;cursor:pointer;}</style><body bgcolor=#33CC33><form name="myForm" method=post><div style="position: absolute;  z-index: 1" id="layer1"><div style="position: absolute;  z-index: 1; visibility:visible" id="mySelectBox"> <div id='scroll_clipper' style='filter:alpha(opacity=<%=selectAlpha%>);position:absolute; width:<%=selectWidth%>px; height: <%=selectHeight%>px; overflow-y:auto'>    <div id='scroll_text' style="background-color:<%=selectBackgroundColor%>;">       <table border="0" cellspacing=0 cellpadding=0 width="100%" id="table1"><%'------------------------------'DSN'------------------------------ set conn=server.createobject("ADODB.CONNECTION") conn.Provider="Microsoft.Jet.OLEDB.4.0" conn.Open(Server.Mappath("/db/northwind.mdb"))'------------------------------'Get data..'------------------------------ set rs = conn.execute("SELECT DISTINCT Country FROM Customers ORDER BY Country")   while not rs.eof  thisCountry = trim(rs(0))   %>           <tr onclick="document.myForm.country.value='<%=thisCountry%>';move_up();showHide();myForm.submit();" style="cursor:pointer;" color="#FFFFFF" onmouseout="this.bgColor='';this.style.color = '';" onmouseover="this.bgColor='<%=selectHighlightColor%>';this.style.color='<%=selectTextHighlightColor%>';">              <td style="padding:0 0 1 2;"><%=thisCountry%></td>           </tr>   <%rs.movenext  wEnd%>       </table>     </div> </div></div><input type="hidden" name="country" value="<%=trim(request("country"))%>" readonly /></div></form><%country = trim(request("country"))if country<>"" thensql="SELECT Customers FROM Customers WHERE country='" & country & "'"set rs=Server.CreateObject("ADODB.Recordset")rs.Open sql,conn %> <table width="100%" cellspacing="0" cellpadding="2" border="1"> <tr> <th>Customers</th> </tr> <%  do until rs.EOF   response.write("<tr>")   response.write("<td>" & rs.fields("Customers") & "</td>")   response.write("</tr>")  rs.MoveNext  loop%>  </table><% end if %><%'------------------------------'Close conn..'------------------------------  rs.close set rs = nothing  conn.close set conn = nothing%></body></html>

?

Link to post
Share on other sites
  • 2 weeks later...
Hey Vin or someone else,Can i ask you one more question about this code?I would like to to , that at the star of this code , before the country is selected, a data from tbl in this DB would be written, and after selection , this data would disapear , and data about selected country would be writen. I inserted som query.string, but , it doesn t work at all   Now only the included file is shown and after selection nothing happens , the included file data is still there....my code[codebox]<%'------------------------------------'These Variables'------------------------------------selectWidth = 200    'width of select box in pixelsselectHeight = 200    'height of select box in pixelsselectAlpha = 80     'transparency of drop-down listselectBackgroundColor = "#00FF00"    'Background colour of drop down listselectHighlightColor = "#FF0000"     'background colour of option when mouse overselectTextHighlightColor = "#FFF"    'text colour of option when mouse over%><script language="javascript">function showHide(){//  if(document.getElementById('mySelectBox').style.visibility=="hidden"){//   document.getElementById('mySelectBox').style.visibility='visible';//  }else{//   document.getElementById('mySelectBox').style.visibility='hidden';//  }}function move_up() {//   scroll_clipper.scrollTop = 0;}</script><style>input{border:none;cursor:pointer;width:100%;padding:2;background-color:transparent;}#customSelect{border:1px solid #c0c0c0;cursor:pointer;}</style><body bgcolor=#33CC33><form name="myForm" method=post><div style="position: absolute;  z-index: 1" id="layer1"><div style="position: absolute;  z-index: 1; visibility:visible" id="mySelectBox"><div id='scroll_clipper' style='filter:alpha(opacity=<%=selectAlpha%>);position:absolute; width:<%=selectWidth%>px; height: <%=selectHeight%>px; overflow-y:auto'>   <div id='scroll_text' style="background-color:<%=selectBackgroundColor%>;">      <table border="0" cellspacing=0 cellpadding=0 width="100%" id="table1"><%'------------------------------'DSN'------------------------------set conn=server.createobject("ADODB.CONNECTION")conn.Provider="Microsoft.Jet.OLEDB.4.0"conn.Open(Server.Mappath("/db/northwind.mdb"))'------------------------------'Get data..'------------------------------set rs = conn.execute("SELECT DISTINCT Country FROM Customers ORDER BY Country")  while not rs.eof Country = trim(rs(0))  %>          <tr onclick="document.myForm.country.value='<%=Country%>';move_up();showHide();myForm.submit();" style="cursor:pointer;" color="#FFFFFF" onmouseout="this.bgColor='';this.style.color = '';" onmouseover="this.bgColor='<%=selectHighlightColor%>';this.style.color='<%=selectTextHighlightColor%>';">             <td style="padding:0 0 1 2;"><%=Country%></td>          </tr>  <%rs.movenext wEnd%>      </table>    </div></div></div><input type="hidden" name="country" value="<%=trim(request("country"))%>" readonly /></div></form><%If Request.QueryString("country") = "" then %><!--#include file=thisiswhatiwouldliketogetbeforeselection.asp--><%else%><%country = trim(request("country"))if country<>"" thensql="SELECT Customers FROM Customers WHERE country='" & country & "'" & Request.QueryString("Country") & "'"set rs=Server.CreateObject("ADODB.Recordset")rs.Open sql,conn%><table width="100%" cellspacing="0" cellpadding="2" border="1"><tr><th>Customers</th></tr><% do until rs.EOF  response.write("<tr>")  response.write("<td>" & rs.fields("Customers") & "</td>")  response.write("</tr>") rs.MoveNext loop%></table><% end if %><%'------------------------------'Close conn..'------------------------------ rs.closeset rs = nothing conn.closeset conn = nothing%><% end if %></body></html>[/codebox]

Edited by aspnetguy
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...