473,322 Members | 1,409 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

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 2385
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

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

Similar topics

1
by: TNG | last post by:
Hi, Question, I use often a combo box on my ASP pages. each time a form is submitted, the value of the combo box returns to the first selection But is there a way to avoid this and show always...
2
by: Nick Calladine | last post by:
Is this possible to ... I wish to get the value of a dropdown select but gets is indexable value (dont know if that is the right term) if that is possible (the position it assigned get assigned...
2
by: David Shorthouse | last post by:
Folks, I have a drop-down select menu generated server-side. I was hoping to pass more than a single variable from the option value to a javascript function. Is this possible? At the moment, my...
1
by: richardscheff | last post by:
Video selector works for IE but not other browsers. for not IE <object ID='Player' data="video/dodgeball.wmv" type="video/x-ms-wmv" width="320" height="280"> <param name="filename"...
5
by: james.calhoun | last post by:
I feel like this should be really easy... I want a hidden field in a form to have its value defined when someone clicks on a link. So if they click on link "A" the value of the hidden field...
9
by: Gregc. | last post by:
Hi I am trying to but a function together whereby the user max a selection and the selection appears in a box on the screen: function goThere(){ var list = document.forms.toy1;...
4
by: IRC | last post by:
hey, i am pretty new on javascript as well as PHP, Hey, anyone can you help me, how to pass the javascript array value to php page......... i want to retrieve the values which are arrayed on...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.