469,313 Members | 2,254 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,313 developers. It's quick & easy.

Change asp variable value from selection options

219 100+
Ok, I'm very new to asp, but this is what I'm trying to accomplish. I want to have a selection drop down list where the user can select a database to load. When they select the database, I want that value to then populate the asp variable named "database". I was hoping I could pass this using javascript, but I don't think I can because asp is server side and javascript is client side.

Any help would be appreciated!

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  5. <title>OpenLink Monitor</title>
  6.     <link rel="stylesheet" type="text/css" href="./css/style.css" />
  7.  
  8. <script>
  9. <!--
  10.  
  11. /*
  12. Auto Refresh Page with Time script
  13. By JavaScript Kit (javascriptkit.com)
  14. Over 200+ free scripts here!
  15. */
  16.  
  17. //enter refresh time in "minutes:seconds" Minutes should range from 0 to inifinity. Seconds should range from 0 to 59
  18. var limit="0:90"
  19.  
  20. if (document.images){
  21.     var parselimit=limit.split(":")
  22.     parselimit=parselimit[0]*60+parselimit[1]*1
  23. }
  24. function beginrefresh(){
  25.     if (!document.images)
  26.         return
  27.     if (parselimit==1)
  28.         window.location.reload()
  29.     else{
  30.         parselimit-=1
  31.         curmin=Math.floor(parselimit/60)
  32.         cursec=parselimit%60
  33.         if (curmin!=0)
  34.             curtime=curmin+" minutes and "+cursec+" seconds left until page refresh!"
  35.         else
  36.             curtime=cursec+" seconds left until page refresh!"
  37.         window.status=curtime
  38.         setTimeout("beginrefresh()",1000)
  39.     }
  40. }
  41.  
  42. window.onload=beginrefresh
  43.  
  44. function changeDb(db_sel){
  45.     alert(db_sel.value)    
  46. }
  47. //-->
  48. </script>
  49.  
  50. <!---adoCon.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=
  51. adoCon.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("oplmodel.mdb")
  52.         strSQL = "SELECT Interface.Name, Interface.Full_name FROM INTERFACE;"
  53. response.write(Server.MapPath("opl_monitor.asp"))
  54. --->
  55.  
  56. <style type="text/css">
  57. <!--
  58. .style2 {font-size: small}
  59. -->
  60. </style>
  61. </head>
  62. <body>
  63.     <%
  64.         Dim adoCon         
  65.         Dim OpenLink    
  66.         Dim strSQL         
  67.         Dim database
  68.  
  69.         Set adoCon = Server.CreateObject("ADODB.Connection")
  70.  
  71.         database="\\grpb\grpb\23040003\Data\OPLT23040003B_TEST2_SFC1.mdb"        
  72.         adoCon.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & database
  73.  
  74.         Set OpenLink = Server.CreateObject("ADODB.Recordset")
  75.         strSQL = "Select ASSOCIATION.ASSOC_NAME,Interface.Full_Name from ASSOCIATION inner join interface on association.assoc_name=interface.name where ASSOCIATION.NAME='OPLENG'"
  76.         getIPInfo = "Select API_LISTEN,ALERT_LISTEN from ENGINE"
  77.  
  78.  
  79.  
  80.         set opls = CreateObject("SMSOPENLINK.SMSOPENLinkSession.1")
  81.         set oplc = CreateObject("SMSOPENLINK.SMSOPENLinkControl.1")
  82.  
  83.         OpenLink.Open getIPInfo, adoCon
  84.  
  85.         opls.ServerPort = OpenLink("API_LISTEN")
  86.         opls.AlertPort=OpenLink("ALERT_LISTEN")
  87.         opls.MachineName = "GRPB"
  88.         opls.OpenPath 3, "OPL_USER"
  89.         retstatus = server.HTMLEncode(opls.LastStatus)
  90.         OpenLink.Close
  91.  
  92.         OpenLink.Open strSQL, adoCon
  93.     %>
  94.  
  95. <h3>OpenLink Monitor v0.1</h3>
  96.  
  97.     <h5>Open Path Return Status: <%=Server.HTMLEncode(retstatus)%></h5>
  98.     <center>
  99.     <span class="style2">Please select the design to monitor:</span>
  100.     <select name="sel_db" OnChange="changeDb(this);return false;">
  101.         <option value="\\grpb\grpb\23040003\Data\OPLT2340_Instruments_B.MDB">TEST - Instruments</option>
  102.         <option value="\\grpb\grpb\23040003\Data\OPLT23040003B_TEST2_SFC1.mdb">TEST - FTP</option>
  103.         <option value="\\grpb\grpb\23040003\Data\oplt2340_FTP_B.mdb">TEST - Main</option>
  104.     </select>
  105.     </center>
  106.     <br />
  107. <table cellspacing=0 align="center">
  108. <tr>
  109.     <th>Interface</th>
  110.     <th>Description</th>
  111.     <th>Status</th>
  112. </tr>
  113.  
  114. <%
  115. Do While not OpenLink.EOF
  116.  
  117.     status_text = oplc.StatusInterface(opls,OpenLink("ASSOC_NAME"))
  118.     Response.Write("<tr>")
  119.     Response.Write("<td>" & OpenLink("ASSOC_NAME") & "</td>")
  120.     Dim myNum
  121.     Dim int_desc
  122.     Dim desc_length
  123.     Dim int_status
  124.     myNum = 5
  125.     int_desc = OpenLink("FULL_NAME")
  126.     desc_length=len(int_desc)
  127.     If desc_length >0 Then
  128.         Response.Write("<td>" &  int_desc & "</td>")
  129.     Else
  130.            Response.Write("<td><i>No Description entered in design</i></td>")
  131.     End If
  132.     int_status = InStr(status_text, "ACTIVE")
  133.     If int_status = 0 then
  134.         Response.Write("<td><b><font color=#FF0000>" & status_text & "</font></b></td>")
  135.     Else
  136.            Response.Write("<td>" & status_text & "</td>")
  137.     End If
  138.     Response.Write("</tr>")
  139.  
  140.     OpenLink.MoveNext
  141. Loop
  142.  
  143. OpenLink.Close
  144. Set OpenLink = Nothing
  145. Set adoCon = Nothing
  146. %>
  147. </table>
  148. <!---
  149.     <%
  150.         set opls = CreateObject("SMSOPENLINK.SMSOPENLinkSession.1")
  151.         set oplc = CreateObject("SMSOPENLINK.SMSOPENLinkControl.1")
  152.  
  153.         opls.ServerPort = "9027"
  154.         opls.AlertPort="9028"
  155.         opls.MachineName = "10.145.34.14"
  156.         opls.OpenPath 3, "OPL_USER"
  157.         retstatus = server.HTMLEncode(opls.LastStatus)
  158.     %>
  159. --->
  160.     <!--- Server number = 3 --->
  161.  
  162. </body>
  163. </html>
  164.  
Jun 16 '08 #1
5 2047
jeffstl
432 Expert 256MB
You have to collect user entered data in ASP either through a submitted form, or a particular querystring link.

So for a drop down, the user would have to choose thier selection, then hit a submit button. Keep in mind however you can have the form action be set to submit to the very same page and just pass a flag to indicate that.

Once its submitted you can get the value. Even if you are populating your drop downs with javascript or using javascript to control thier interactions with it.

For example:

Expand|Select|Wrap|Line Numbers
  1. <form action="mypage.asp" method="post">
  2. <select name="dd1">
  3. <option>Whatever</option>
  4. </select>
  5. <input type="hidden" name="Mode" Value="S">
  6. <input type="submit" name="btnSubmit">
  7.  
  8. 'Bottom line is just put the following code then at the top of your page to handle the collection of this data. 
  9. dim MyMode
  10. dim MyDropDownValue
  11. MyMode = request.form("Mode")
  12. if MyMode = "S" then
  13.      'get your value
  14.      MyDropDownValue = request.form("dd1")     
  15. end if
  16.  
  17.  
Is this what you needed\help?
Jun 17 '08 #2
DrBunchman
979 Expert 512MB
As a further comment to Jeff's excellent answer, you could also have your form automatically submit using javascript once an option was selected from the drop down.

Dr B
Jun 17 '08 #3
dmorand
219 100+
This is what I ended up doing. I've ran into another problem though, and not really sure how to get past it. The page I created needs to be refreshed every minute. When the page goes to refresh it pops up that message that data needs to be resent to the server. This is because I have a POST form on my page. How can I get around this so that the message doesn't come up, and the page automatically refreshes??
Jun 18 '08 #4
DrBunchman
979 Expert 512MB
I don't believe it's possible to disable the message - it's there to stop people from accidentally resubmitting data which could lead to them doing things like paying for items twice.

I see two possible solutions to your problem.
  1. Rather than refreshing the page when the timer hits the interval you could redirect the page to itself. You would lose any request variables (unless you passed them through the querystring) but you wouldn't get the re-posting message.
  2. You could use AJAX to refresh only the portion of the screen that you are interested in - check out this tutorial on the basics of AJAX for some more info.
Hope this helps,

Dr B
Jun 19 '08 #5
dmorand
219 100+
Thanks Dr B, I'll check out that link!!
Jun 19 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by TNG | last post: by
2 posts views Thread by David Shorthouse | last post: by
1 post views Thread by richardscheff | last post: by
9 posts views Thread by Gregc. | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.