Passing a value from a HTML button to another ASP page HELP!

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • djjohnst

    Passing a value from a HTML button to another ASP page HELP!

    I am creating a program that will list program times for people who
    visit our website. Users can login create, edit, delete a program.
    These dump into a database. The ASP webpage then reads from the
    database and posts these programs for people to view (program type,
    date, time, etc...). I am having trouble creating an edit option. When
    bring up the edit page i want it to read the database and dynamically
    create a table that has a button for each record in the recordset. I
    want to be able to click that "edit" button and in a new window the
    form appears filled out with the current record's information filled
    in. However, to do this I am having trouble pulling out the button
    name (which is the name of the DB primary key survey num) and passing
    it to the other edit form. Some help me....PS i know the below code is
    incorrect because it passes 28 which is the last record in the record
    set, not the current. I know why it does this, I just do not know how
    to fix it.


    RSSQL = "Select * from Workshops where workshopdate Date()"
    rs.open RSSQL,conn,1,1

    if rs.recordcount = 0 then
    %There are no upcoming workshops.
    <%
    response.end
    end if

    rs.movefirst

    %>
    <table width="499" border="1">
    <tr>
    <th width="139" scope="col"><di v align="center"> Date</th>
    <th width="300" scope="col"><di v align="center"> Time</th>
    <th width="300" scope="col"><di v align="center"> Location</th>
    </tr>
    <%

    Do until rs.eof
    WorkshopNum = rs("WorkshopNum ")
    WorkshopDate = rs ("WorkshopDate" )
    WorkshopStartTi me = rs("WorkshopSta rtTime")
    WorkshopEndTime = rs("WorkshopEnd Time")
    WorkshopLocatio n = rs("WorkshopLoc ation")

    StartTime = Instr(WorkshopS tartTime,":")
    EndTime = Instr(WorkshopE ndTime,":")
    StartAMPM = right(WorkshopS tartTime, 2)
    EndAMPM=right(W orkshopEndTime, 2)

    WorkshopStartTi me=Left(Worksho pStartTime, StartTime+2)
    WorkshopEndTime =Left(WorkshopE ndTime, EndTime+2)

    %>
    <tr>
    <td><div align="center"> <%Response.writ e WorkshopDate%></td>
    <td><div align="center"> <%Response.writ e WorkshopStartTi me &
    StartAMPM & "-" & WorkshopEndTime & EndAMPM%></td>
    <td><div align="center"> <%Response.writ e WorkshopLocatio n%></td>
    <td>
    <input name="<%Respons e.Write WorkshopNum%>" type=Button onclick=
    "window.open('e ditworkshop111. asp'); " value="Edit This Workshop"></
    td>
    </tr>
    <%

    session("worksh opnum")= workshopnum

    rs.movenext

    loop

    %>

  • Adrienne Boswell

    #2
    Re: Passing a value from a HTML button to another ASP page HELP!

    Gazing into my crystal ball I observed djjohnst <djjohnst@gmail .com>
    writing in news:1178807067 .841162.187400@ l77g2000hsb.goo glegroups.com:
    I am creating a program that will list program times for people who
    visit our website. Users can login create, edit, delete a program.
    These dump into a database. The ASP webpage then reads from the
    database and posts these programs for people to view (program type,
    date, time, etc...). I am having trouble creating an edit option. When
    bring up the edit page i want it to read the database and dynamically
    create a table that has a button for each record in the recordset. I
    want to be able to click that "edit" button and in a new window the
    form appears filled out with the current record's information filled
    in.
    Does it have to open in a new window? What about people who hate windows
    spawning, like me? Just an observation.
    However, to do this I am having trouble pulling out the button
    name (which is the name of the DB primary key survey num) and passing
    it to the other edit form. Some help me....PS i know the below code is
    incorrect because it passes 28 which is the last record in the record
    set, not the current. I know why it does this, I just do not know how
    to fix it.
    >
    >
    RSSQL = "Select * from Workshops where workshopdate Date()"
    Please do not use * to select fields - name the fields individually.
    rs.open RSSQL,conn,1,1
    >
    if rs.recordcount = 0 then
    %There are no upcoming workshops.
    <%
    response.end
    end if
    >
    rs.movefirst
    >
    %>
    ><table width="499" border="1">
    <tr>
    <th width="139" scope="col"><di v align="center"> Date</th>
    <th width="300" scope="col"><di v align="center"> Time</th>
    <th width="300" scope="col"><di v align="center"> Location</th>
    </tr>
    No need for <div align="center"o n a th element. It natively does that.
    Better to get rid of presentational markup and use CSS.
    ><%
    >
    Do until rs.eof
    WorkshopNum = rs("WorkshopNum ")
    WorkshopDate = rs ("WorkshopDate" )
    WorkshopStartTi me = rs("WorkshopSta rtTime")
    WorkshopEndTime = rs("WorkshopEnd Time")
    WorkshopLocatio n = rs("WorkshopLoc ation")
    >
    StartTime = Instr(WorkshopS tartTime,":")
    EndTime = Instr(WorkshopE ndTime,":")
    StartAMPM = right(WorkshopS tartTime, 2)
    EndAMPM=right(W orkshopEndTime, 2)
    >
    WorkshopStartTi me=Left(Worksho pStartTime, StartTime+2)
    WorkshopEndTime =Left(WorkshopE ndTime, EndTime+2)
    >
    %>
    <tr>
    <td><div align="center"> <%Response.writ e WorkshopDate%></td>
    <td><div align="center"> <%Response.writ e WorkshopStartTi me &
    StartAMPM & "-" & WorkshopEndTime & EndAMPM%></td>
    <td><div align="center"> <%Response.writ e WorkshopLocatio n%></td>
    <td>
    <input name="<%Respons e.Write WorkshopNum%>" type=Button onclick=
    "window.open('e ditworkshop111. asp'); " value="Edit This Workshop"></
    td>
    </tr>
    Where is workshopnum here? Oh - it's not, it's down below and changes as
    it loops through. That won't work. You have to put the value somewhere
    in an input element. Naming the input element is not going to work
    either, because you would have to test for that name coming in from the
    request.

    What you need is something like name="field" value="<%=works hopnum%>", or
    you would put it in a querystring, eg. "window.open('e ditworkshop111. asp?
    field=<%=worksh opnum%>');" Then you can get the value from
    reques.querystr ing.
    ><%
    >
    session("worksh opnum")= workshopnum
    >
    rs.movenext
    >
    loop
    >
    %>
    >
    >
    You might want to think about using getrows() as well.

    --
    Adrienne Boswell at Home
    Arbpen Web Site Design Services
    Arbpen Consulting will help you harness valuable insights and translate them into tangible results by merging data and strategy.

    Please respond to the group so others can share

    Comment

    • djjohnst

      #3
      Re: Passing a value from a HTML button to another ASP page HELP!

      Thanx for the response!!!

      The thing is that it actually does pass the value of workshopnum to
      the buttons! I just don't know how to pull that info out once it is
      clicked. The reason i know it works is cause i'll changed

      <input name="<%Respons e.Write WorkshopNum%>" type=Button onclick=
      "window.open('e ditworkshop111. asp'); " value="Edit This Workshop">

      to

      <input name="<%Respons e.Write WorkshopNum%>" type=Button onclick=
      "window.open('e ditworkshop111. asp'); " value="%Respons e.Write
      WorkshopNum%">

      and the buttons appeared 23, 24,25,26...etc.

      I just want that number to go somewhere once it is clicked so I can
      use that number.

      Also I agree with the hating new windows poping up. I'll change that
      but in the mean time I need to figure this first part out...Any other
      advice!

      Comment

      • Evertjan.

        #4
        Re: Passing a value from a HTML button to another ASP page HELP!

        djjohnst wrote on 10 mei 2007 in microsoft.publi c.inetserver.as p.general:
        <input name="<%Respons e.Write WorkshopNum%>" type=Button onclick=
        "window.open('e ditworkshop111. asp'); " value="Edit This Workshop">
        >
        <input
        type=Button
        onclick="window .open('editw.as p?wNum=<%=Works hopNum%>')"
        value="Edit This Workshop">

        and in the "editw.asp" file:

        <% 'vbs
        WorkshopNum = request.queryst ring("wNum")
        %>

        --
        Evertjan.
        The Netherlands.
        (Please change the x'es to dots in my emailaddress)

        Comment

        • djjohnst

          #5
          Re: Passing a value from a HTML button to another ASP page HELP!

          YES! that worked!! I want to give you a big kiss!!! Thank you so much!

          Comment

          • Evertjan.

            #6
            Re: Passing a value from a HTML button to another ASP page HELP!

            djjohnst wrote on 10 mei 2007 in microsoft.publi c.inetserver.as p.general:
            YES! that worked!! I want to give you a big kiss!!! Thank you so much!
            Even so, it would be better if you quote what you are replying on,
            since we then would know what you are talking about.

            After all, this is usenet.

            --
            Evertjan.
            The Netherlands.
            (Please change the x'es to dots in my emailaddress)

            Comment

            • djjohnst

              #7
              Re: Passing a value from a HTML button to another ASP page HELP!

              haha forgive me...

              what worked was as follows:

              <input name="<%Respons e.Write WorkshopNum%>" type=Button onclick=
              "window.open('e ditWorkshop111. asp?wNum=<%=Wor kshopNum%>')" value="Edit
              This Workshop"></td>

              Comment

              Working...