Change asp variable value from selection options

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dmorand
    New Member
    • Sep 2007
    • 219

    Change asp variable value from selection options

    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!

    [code=html]
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>OpenLi nk Monitor</title>
    <link rel="stylesheet " type="text/css" href="./css/style.css" />

    <script>
    <!--

    /*
    Auto Refresh Page with Time script
    By JavaScript Kit (javascriptkit. com)
    Over 200+ free scripts here!
    */

    //enter refresh time in "minutes:second s" Minutes should range from 0 to inifinity. Seconds should range from 0 to 59
    var limit="0:90"

    if (document.image s){
    var parselimit=limi t.split(":")
    parselimit=pars elimit[0]*60+parselimit[1]*1
    }
    function beginrefresh(){
    if (!document.imag es)
    return
    if (parselimit==1)
    window.location .reload()
    else{
    parselimit-=1
    curmin=Math.flo or(parselimit/60)
    cursec=parselim it%60
    if (curmin!=0)
    curtime=curmin+ " minutes and "+cursec+" seconds left until page refresh!"
    else
    curtime=cursec+ " seconds left until page refresh!"
    window.status=c urtime
    setTimeout("beg inrefresh()",10 00)
    }
    }

    window.onload=b eginrefresh

    function changeDb(db_sel ){
    alert(db_sel.va lue)
    }
    //-->
    </script>

    <!---adoCon.Open "Provider=Micro soft.Jet.OLEDB. 4.0; Data Source=
    adoCon.Open "Provider=Micro soft.Jet.OLEDB. 4.0; Data Source=" & Server.MapPath( "oplmodel.m db")
    strSQL = "SELECT Interface.Name, Interface.Full_ name FROM INTERFACE;"
    response.write( Server.MapPath( "opl_monitor.as p"))
    --->

    <style type="text/css">
    <!--
    .style2 {font-size: small}
    -->
    </style>
    </head>
    <body>
    <%
    Dim adoCon
    Dim OpenLink
    Dim strSQL
    Dim database

    Set adoCon = Server.CreateOb ject("ADODB.Con nection")

    database="\\grp b\grpb\23040003 \Data\OPLT23040 003B_TEST2_SFC1 .mdb"
    adoCon.Open "Provider=Micro soft.Jet.OLEDB. 4.0; Data Source=" & database

    Set OpenLink = Server.CreateOb ject("ADODB.Rec ordset")
    strSQL = "Select ASSOCIATION.ASS OC_NAME,Interfa ce.Full_Name from ASSOCIATION inner join interface on association.ass oc_name=interfa ce.name where ASSOCIATION.NAM E='OPLENG'"
    getIPInfo = "Select API_LISTEN,ALER T_LISTEN from ENGINE"



    set opls = CreateObject("S MSOPENLINK.SMSO PENLinkSession. 1")
    set oplc = CreateObject("S MSOPENLINK.SMSO PENLinkControl. 1")

    OpenLink.Open getIPInfo, adoCon

    opls.ServerPort = OpenLink("API_L ISTEN")
    opls.AlertPort= OpenLink("ALERT _LISTEN")
    opls.MachineNam e = "GRPB"
    opls.OpenPath 3, "OPL_USER"
    retstatus = server.HTMLEnco de(opls.LastSta tus)
    OpenLink.Close

    OpenLink.Open strSQL, adoCon
    %>

    <h3>OpenLink Monitor v0.1</h3>

    <h5>Open Path Return Status: <%=Server.HTMLE ncode(retstatus )%></h5>
    <center>
    <span class="style2"> Please select the design to monitor:</span>
    <select name="sel_db" OnChange="chang eDb(this);retur n false;">
    <option value="\\grpb\g rpb\23040003\Da ta\OPLT2340_Ins truments_B.MDB" >TEST - Instruments</option>
    <option value="\\grpb\g rpb\23040003\Da ta\OPLT23040003 B_TEST2_SFC1.md b">TEST - FTP</option>
    <option value="\\grpb\g rpb\23040003\Da ta\oplt2340_FTP _B.mdb">TEST - Main</option>
    </select>
    </center>
    <br />
    <table cellspacing=0 align="center">
    <tr>
    <th>Interface </th>
    <th>Description </th>
    <th>Status</th>
    </tr>

    <%
    Do While not OpenLink.EOF

    status_text = oplc.StatusInte rface(opls,Open Link("ASSOC_NAM E"))
    Response.Write( "<tr>")
    Response.Write( "<td>" & OpenLink("ASSOC _NAME") & "</td>")
    Dim myNum
    Dim int_desc
    Dim desc_length
    Dim int_status
    myNum = 5
    int_desc = OpenLink("FULL_ NAME")
    desc_length=len (int_desc)
    If desc_length >0 Then
    Response.Write( "<td>" & int_desc & "</td>")
    Else
    Response.Write( "<td><i>No Description entered in design</i></td>")
    End If
    int_status = InStr(status_te xt, "ACTIVE")
    If int_status = 0 then
    Response.Write( "<td><b><fo nt color=#FF0000>" & status_text & "</font></b></td>")
    Else
    Response.Write( "<td>" & status_text & "</td>")
    End If
    Response.Write( "</tr>")

    OpenLink.MoveNe xt
    Loop

    OpenLink.Close
    Set OpenLink = Nothing
    Set adoCon = Nothing
    %>
    </table>
    <!---
    <%
    set opls = CreateObject("S MSOPENLINK.SMSO PENLinkSession. 1")
    set oplc = CreateObject("S MSOPENLINK.SMSO PENLinkControl. 1")

    opls.ServerPort = "9027"
    opls.AlertPort= "9028"
    opls.MachineNam e = "10.145.34. 14"
    opls.OpenPath 3, "OPL_USER"
    retstatus = server.HTMLEnco de(opls.LastSta tus)
    %>
    --->
    <!--- Server number = 3 --->

    </body>
    </html>
    [/code]
  • jeffstl
    Recognized Expert Contributor
    • Feb 2008
    • 432

    #2
    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:

    Code:
    <form action="mypage.asp" method="post">
    <select name="dd1">
    <option>Whatever</option>
    </select>
    <input type="hidden" name="Mode" Value="S">
    <input type="submit" name="btnSubmit">
    
    'Bottom line is just put the following code then at the top of your page to handle the collection of this data. 
    dim MyMode
    dim MyDropDownValue
    MyMode = request.form("Mode")
    if MyMode = "S" then
         'get your value
         MyDropDownValue = request.form("dd1")     
    end if
    Is this what you needed\help?

    Comment

    • DrBunchman
      Recognized Expert Contributor
      • Jan 2008
      • 979

      #3
      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

      Comment

      • dmorand
        New Member
        • Sep 2007
        • 219

        #4
        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??

        Comment

        • DrBunchman
          Recognized Expert Contributor
          • Jan 2008
          • 979

          #5
          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

          Comment

          • dmorand
            New Member
            • Sep 2007
            • 219

            #6
            Thanks Dr B, I'll check out that link!!

            Comment

            Working...