473,657 Members | 2,418 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Change asp variable value from selection options

219 New Member
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 2408
jeffstl
432 Recognized Expert Contributor
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 Recognized Expert Contributor
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 New Member
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 Recognized Expert Contributor
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 New Member
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
1869
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 your latest selection ? Thx in advance TNG
2
1852
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 by the position on the list) this is so i can then pass it to the array called pictureimage to get the correct filename (similar to the picturetext part of this routine) and then the final line on the fuction is to change an original image with...
2
12320
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 option values consist of three numbers separated by commas. I thought I could pass these three numbers as three distinct variables to the javascript function, but it obviously doesn't work this way. e.g.
1
7620
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" value="video/dodgeball.wmv" /> <param name="ShowControls\" value="1" /> <param name="AutoStart\" value="1" /> <param name="PlayCount\" value="1" />
5
6844
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 becomes "A", while if they click "B" the value of hidden field becomes "B" Help?
9
2637
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; location.href=list.options; }
4
4333
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 "selectedValues" from next page for php variable this is my javascript code saved on "sendValue.js" file, <script> function updateRecordEntry(requestValue){
0
8402
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8315
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8734
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8608
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6172
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5633
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4323
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2733
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1962
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.