Please help me in my last step in my website... having 2 buttons in the same page.. [Answered]RSS

16 replies

Last post Jan 19, 2011 02:42 PM by hdhd

  • Please help me in my last step in my website... having 2 buttons in the same page..

    Jan 16, 2011 04:16 AM|hdhd|LINK

      <div>Hi there,

    I have built a web site with asp and I used MS access data base..
    I have one problem that I did not know how to do it to finish my website..
    so my code is as:


    <!-- #include file="LALib.asp" -->
    <%


    Dim iBidNeeded

    sCMD = "" & Ucase(RequestValue("CMD"))
    sUserName = "" & RequestValue("UserName")
    sPassword = "" & RequestValue("Password")
    iBidPlaced = FVal(RequestValue("Bid"))
    lItemID = FVal(RequestValue("ItemID"))
    'lAucID = FVal(RequestValue("AucID"))

    DoPageHeader
    OpenDBConn


    gsSQL = "SELECT aucEnded,aucEmailsSent,aucItemOwner,aucItemTitle,a ucCategoryID,aucImageURL," & _
    "aucAvailDate,aucCloseDate,aucStartingBid,aucMinimu mIncrement,aucCurrentBid,aucCurrentBidder,aucDescr iption," & _
    "regUserName, regEmail, regCity, regState, regCountry " & _
    "FROM tblLAwaittoconfirm LEFT JOIN tblLARegistration on tblLAwaittoconfirm.aucItemOwner = tblLARegistration.regID " & _
    "WHERE aucID = " & SQLVal(lItemID)
    Set rs = gobjConnect.Execute(gsSQL)

    If not rs.EOF then
    ShowDetail
    Select Case sCmd
    Case "DELETE"
    'ShowDetail
    DeleteItem
    'Case "ADD"
    'AddItem
    'Case Else
    ' ShowDetail
    End Select

    'ShowDetail
    Else
    TableHead(GLS_ItemDetail)
    Response.Write "<P align=""CENTER"">" & gsErrorTextOpen & GLS_InvalidItem & gsErrorTextClose & "</P>"
    End If

    Select Case sCmd
    Case "DELETE"
    DeleteItem
    'Case "ADD"
    'AddItem
    'Case Else
    End Select



    rs.Close
    set rs = nothing
    'TableFoot
    DoPageFooter
    CloseDBConn

    Sub AddItem
    'Sub InsertAd

    Set rsAuc = Server.CreateObject("ADODB.RecordSet")
    rsAuc.Open "tblLAAuctions", gobjConnect, 1, 3, &H0002 'adOpenKeyset, adLockOptimistic, adCmdTable
    rsAuc.AddNew


    rsAuc("aucItemOwner") = rs.Fields("aucItemOwner")
    rsAuc("aucItemTitle") = rs.Fields("aucItemTitle")
    rsAuc("aucCategoryID") = rs.Fields("aucCategoryID")
    rsAuc("aucImageURL") = rs.Fields("aucImageURL")
    rsAuc("aucEnded") = "N"
    rsAuc("aucEmailsSent") = "N"
    rsAuc("aucAvailDate") = rs.Fields("aucAvailDate")
    rsAuc("aucCloseDate") = rs.Fields("aucCloseDate")
    rsAuc("aucStartingBid") = rs.Fields("aucStartingBid")
    rsAuc("aucMinimumIncrement") = rs.Fields("aucMinimumIncrement")
    rsAuc("aucCurrentBid") = rs.Fields("aucCurrentBid")
    rsAuc("aucCurrentBidder") = rs.Fields("aucCurrentBidder")
    rsAuc("aucDescription") = rs.Fields("aucDescription")
    rsAuc.Update

    lAucID = rsAuc("aucID")
    rsAuc.Close
    set rsAuc = Nothing

    'Response.Write "<BR>" & gsAuctionTextOpen & GLS_SuccessfulPost & "<BR>"
    Response.Write "<BR>" & "Item is approved and submitted" & "<BR>"

    DeleteItem

    'Response.Write GLS_PostView & "<A href=""LAViewItem.asp?ItemID=" & lAucID & """>" & gsAucURL & "LAViewItem.asp?ItemID=" & lAucID & "</A>" & gsAuctionTextClose &"<BR><BR>"

    End Sub

    Sub DeleteItem
    sSQL = "DELETE from tblLAwaittoconfirm WHERE aucID=" & SQLVal(lItemID)
    gobjConnect.Execute sSQL
    Response.Write gsAuctionTextOpen & GLS_AdmDADeleteSuccess & gsAuctionTextClose
    End Sub

    Sub ShowDetail
    Response.Write "<FORM METHOD=""POST"" ACTION=""LAAdmViewItem.asp"">"
    <div style="margin: 5px 20px 20px;"> <div class="smallfont" style="margin-bottom: 2px;"> Code:</div>

    Original - Code

    <div dir="ltr" style="text-align: left;"><div>
      Response.Write "<INPUT TYPE=""HIDDEN"" NAME=""CMD"" VALUE=""DELETE"">"
    </div></div>
    </div>

    Response.Write gsAuctionTitleOpen & rs.Fields("aucItemTitle") & "<BR>" & gsAuctionTextOpen & GLS_AuctionID & "&nbsp;" & lItemID & gsAuctionTextClose & gsAuctionTitleClose
    TableHead(GLS_ItemDetail)
    If rs.Fields("aucCloseDate") < NOW Then
    Response.Write gsLabelOpen & "<FONT COLOR=""RED"">" & GLS_BiddingClosed & "</CENTER>" & gsLabelClose & "<BR>"
    bEmailsSent = EvalBool(rs.Fields("aucEmailsSent"))
    Call CloseAuction(lItemID, bEmailsSent)
    End If

    Response.Write "<TABLE BORDER=""0"" WIDTH=""100%"" CELLSPACING=""0"" CELLPADDING=""3"">"

    'Headings
    Response.Write "<TR><TD>" & gsLabelOpen & GLS_StartBidDet & gsLabelClose & "</TD>"
    Response.Write "<TD>" & gsAuctionTextOpen & FCurrency(rs.Fields("aucStartingBid")) & gsAuctionTextClose & "</TD>"
    Response.Write "<TD>&nbsp;</TD></TR>"
    Response.Write "<TR><TD>" & gsLabelOpen & GLS_StartDateDet & gsLabelClose & "</TD>"
    Response.Write "<TD>" & gsAuctionTextOpen & DispShortDateTime(rs.Fields("aucAvailDate")) & gsAuctionTextClose & "</TD></TR>"

    Response.Write "<TR><TD>" & gsLabelOpen & GLS_CurrentBidDet & gsLabelClose & "</TD>"
    Response.Write "<TD>" & gsAuctionTextOpen
    If FVal(rs.Fields("aucCurrentBid")) > 0 then
    Response.Write FCurrency(rs.Fields("aucCurrentBid"))
    Else
    Response.Write GLS_NA
    End If
    Response.Write gsAuctionTextClose & "</TD>"
    Response.Write "<TD>&nbsp;</TD></TR>"

    Response.Write "<TR><TD>" & gsLabelOpen & GLS_LocationDet & gsLabelClose & "</TD>"
    Response.Write "<TD>" & gsAuctionTextOpen & rs.Fields("regCity") & ", " & rs.Fields("regState") & " " & rs.Fields("regCountry") & gsAuctionTextClose & "</TD></TR>"

    Response.Write "<TR><TD>" & gsLabelOpen & GLS_ClosesDet & gsLabelClose & "</TD>"
    Response.Write "<TD>" & gsAuctionTextOpen & DispShortDateTime(rs.Fields("aucCloseDate")) & gsAuctionTextClose & gsAuctionTextCloses & "</TD>"

    Response.Write "<TD>&nbsp;</TD></TR>"

    Response.Write "<TR><TD>" & gsLabelOpen & GLS_OwnerDet & gsLabelClose & "</TD>"
    Response.Write "<TD>" & gsAuctionTextOpen & "<A HREF = ""mailto:" & rs.fields("regEmail") & chr(34) & ">" & rs.Fields("regUserName") & "</A>"
    Response.Write gsAuctionTextClose & "</TD>"
    Response.Write "</TR>"

    'Response.Write "<TR BGCOLOR=""" & gsLineColor & """><TD COLSPAN=""5""></TD></TR>"

    'Description
    Response.Write "<TR><TD>" & gsSubHeadOpen & GLS_DescriptionDet & gsSubHeadClose & "<BR>"
    Response.Write gsAuctionTextOpen & rs.Fields("aucDescription") & gsAuctionTextClose & "</TD></TR>"

    'Check for image
    If LEN(TRIM(rs.Fields("aucImageURL"))) <> 0 Then
    Response.Write "<TR><TD colspan=""5""><CENTER><IMG BORDER=""0"" src=""" & rs.Fields("aucImageURL") & """></CENTER></TD></TR>"
    End If

    'Response.Write "</TABLE>"
    Response.Write "</TD></TR>"

    Response.Write "</TABLE>"

    <div style="margin: 5px 20px 20px;">

    <div dir="ltr" style="text-align: left;"><div>
      Response.Write "<INPUT TYPE=""HIDDEN"" NAME=""CMD"" VALUE=""ADD"">"
          'Response.Write "<INPUT TYPE=""SUBMIT"" VALUE=""ADD"">"

         
          Response.Write "<INPUT TYPE=""SUBMIT"" VALUE=""DELETE"">"
    </div></div>
    </div>


    Response. Write "</FORM>"

    End Sub


    %>

    I have highlighted the thing that I want..
    I want to add two buttuns one for add and one for delete.. but I have tried to change their posions in this code, but nothing success with me..
    so, can you help me in making pressing the add button call the ADDITEM and pressing the delete button call the DELETEITEM..

    Waiting for your help..

    Thanks so much..
    </div>

  • Re: Please help me in my last step in my website... having 2 buttons in the same page..

    Jan 16, 2011 12:48 PM|tomkmvp|LINK

    hdhd

    I want to add two buttuns one for add and one for delete.. but I have tried to change their posions in this code, but nothing success with me..
    so, can you help me in making pressing the add button call the ADDITEM and pressing the delete button call the DELETEITEM..

    In your ASP code, test the value of buttonchoice and then call the correct sub.

    Tom Kaminski (former IIS MVP 2002-2010)
    http://mvp.support.microsoft.com/
  • Re: Please help me in my last step in my website... having 2 buttons in the same page..

    Jan 17, 2011 12:11 AM|hdhd|LINK

    tomkmvp

    hdhd

    I want to add two buttuns one for add and one for delete.. but I have tried to change their posions in this code, but nothing success with me..
    so, can you help me in making pressing the add button call the ADDITEM and pressing the delete button call the DELETEITEM..

    In your ASP code, test the value of buttonchoice and then call the correct sub.

     

     

    Thank you so much..

    but I tried the following:

    Response.Write "<INPUT TYPE=""HIDDEN"" NAME=""CMD"" VALUE=""ADD"">"
        Response.Write "<INPUT TYPE=""button"" VALUE=""ADD"" OnClick=""AddItem"">"

        Response.Write "<INPUT TYPE=""HIDDEN"" NAME=""CMD"" VALUE=""DELETE"">"
        Response.Write "<INPUT TYPE=""button"" VALUE=""DELETE"" OnClick=""DeleteItem"">"

    but nothing happen no action taken or no subroutine call when pressing any of the button..

    Do you think the problem in this sentence where "LAAdmViewITem.asp" is the same page opened?:

    Response.Write "<FORM METHOD=""POST"" ACTION=""LAAdmViewItem.asp"">"

     I am waiting to your answer

    thanks

  • Re: Please help me in my last step in my website... having 2 buttons in the same page..

    Jan 17, 2011 08:35 AM|tomkmvp|LINK

    The client-side button onclick can't call the server-side functions, you need to create the same setButton client script in your code along with the buttonChoice hidden field.  In your server code you then need to test the value of Request.Form("buttonChoice"), if it's equal to "ADD" then you call your AddItem function, otherwise call DeleteItem.

    Tom Kaminski (former IIS MVP 2002-2010)
    http://mvp.support.microsoft.com/
  • Re: Please help me in my last step in my website... having 2 buttons in the same page..

    Jan 17, 2011 02:53 PM|hdhd|LINK

    First if I call AddItem and DeleteItem it works, but when I tryed the following:

    Response.Write "<INPUT TYPE=""SUBMIT"" VALUE=""ADD""    name=""SubmitButton"">"

    Response.Write "<INPUT TYPE=""SUBMIT"" VALUE=""DELETE"" name=""SubmitButton"">"

     

    and as public I put:

    Dim buttonPressed

    buttonPressed= Request.Form ("SubmitButton")

    Select Case buttonPressed
    Case "DELETE"
               DeleteItem
    Case "ADD"
              AddItem
    End Select

     

    When I press the button Add it give me the following error:

    ADODB.Recordset error '800a0bcd'

    Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.

    /LaptopAuction/LAAdmViewItem.asp, line 68

     

    And when I pree ADD button It give me nothing and nothing is deleted..

     

    Can you help me again..

    Thanks

     

  • Re: Please help me in my last step in my website... having 2 buttons in the same page..

    Jan 18, 2011 01:00 AM|hdhd|LINK

     I was wondering why when I call AddItem and DeleteItem alone they work perfectly and when I use them with the Add and Delete button For the add it give me the folloing error:

     

    ADODB.Recordset error '800a0bcd'

    Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.

    /LaptopAuction/LAAdmViewItem.asp, line 76

     

    and when I tried deleteItem, no action are taken, but it goes inside the sub..

    you can see the problem here:

     http://www.laptopsauction.somee.com/LaptopAuction/LAAdmLogin.asp

    the username and password are: admin and admin

    Then go to create auction -> select any category -> select any auction -> see the problem when you press add or delete..

     

    Please help me as soon as possible..

     Thanks

     

  • Re: Please help me in my last step in my website... having 2 buttons in the same page..

    Jan 18, 2011 08:28 AM|tomkmvp|LINK

    Show the current version of your code.

    Tom Kaminski (former IIS MVP 2002-2010)
    http://mvp.support.microsoft.com/
  • Re: Please help me in my last step in my website... having 2 buttons in the same page..

    Jan 18, 2011 10:43 AM|hdhd|LINK

    I think 3.5 is that what you want?

  • Re: Please help me in my last step in my website... having 2 buttons in the same page..

    Jan 18, 2011 12:18 PM|tomkmvp|LINK

    No, I mean your actual ASP code that you are running.  : )

    Tom Kaminski (former IIS MVP 2002-2010)
    http://mvp.support.microsoft.com/
  • Re: Please help me in my last step in my website... having 2 buttons in the same page..

    Jan 18, 2011 12:44 PM|hdhd|LINK

     from where i can get it?

  • Re: Please help me in my last step in my website... having 2 buttons in the same page..

    Jan 18, 2011 04:12 PM|tomkmvp|LINK

    ... your .asp file ... it would help to see the complete file so i can see the changes you have made ...

    Tom Kaminski (former IIS MVP 2002-2010)
    http://mvp.support.microsoft.com/
  • Re: Please help me in my last step in my website... having 2 buttons in the same page..

    Jan 18, 2011 04:16 PM|hdhd|LINK

     do you want me to attach the the whole project or just this file?

  • Re: Please help me in my last step in my website... having 2 buttons in the same page..

    Jan 18, 2011 04:43 PM|tomkmvp|LINK

    just the file we've been talking about.

    Tom Kaminski (former IIS MVP 2002-2010)
    http://mvp.support.microsoft.com/
  • Re: Please help me in my last step in my website... having 2 buttons in the same page..

    Jan 18, 2011 04:55 PM|hdhd|LINK

     http://www.2shared.com/document/TW2tXXdC/LAAdmViewItem.html

    this is the file..

    I think the problem in the database connection because I tried it  and the calling is done, but the function for exeuting the database is not executed..

     Thanks so much

  • Re: Please help me in my last step in my website... having 2 buttons in the same page..

    Jan 18, 2011 06:00 PM|hdhd|LINK

     I think I have some clue about the problem..

    first the program process the following:

    Dim iBidNeeded
    Dim buttonPressed

           
        sCMD = "" & Ucase(RequestValue("CMD"))
        sUserName   = "" & RequestValue("UserName")
        sPassword   = "" & RequestValue("Password")
        iBidPlaced  = FVal(RequestValue("Bid"))
        lItemID     = FVal(RequestValue("ItemID"))
        'lAucID = FVal(RequestValue("AucID"))

       
        DoPageHeader
        OpenDBConn

    buttonPressed= "" & Ucase(Request.Form ("SubmitButton"))

       
        gsSQL = "SELECT aucEnded,aucEmailsSent,aucItemOwner,aucItemTitle,aucCategoryID,aucImageURL," & _
                "aucAvailDate,aucCloseDate,aucStartingBid,aucMinimumIncrement,aucCurrentBid,aucCurrentBidder,aucDescription," & _
                "regUserName, regEmail, regCity, regState, regCountry " & _
                "FROM tblLAwaittoconfirm LEFT JOIN tblLARegistration on tblLAwaittoconfirm.aucItemOwner = tblLARegistration.regID " & _
                "WHERE aucID = " & SQLVal(lItemID)
        Set rs = gobjConnect.Execute(gsSQL)
       
        If not rs.EOF then
          ShowDetail


        'Else
         'TableHead(GLS_ItemDetail)
         'Response.Write "<P align=""CENTER"">" & gsErrorTextOpen & GLS_InvalidItem & gsErrorTextClose & "</P>"
        End If


    Select Case buttonPressed
    Case "DELETE"
            DeleteItem
    Case "ADD"
            AddItem 
    Case Else
    Response.Write " Case Else"
    End Select

       
           
        rs.Close
        set rs = nothing
        'TableFoot
        DoPageFooter
        CloseDBConn

    so "SELECT CASE BUTTONPRESSED" for the first time it gave "CASE ELSE" and when I press one of the buttons"ADD" or "DELETE" the database connection will be closed..

    I think the secret is in the place of  "Select Case buttonPressed", so where I suppose to put it to execute this case after pushing one of the buttons..

    Thanks..

  • Re: Please help me in my last step in my website... having 2 buttons in the same page..

    Jan 19, 2011 08:34 AM|tomkmvp|LINK

    You need to re-arrange your code so your subs for ADD and DELETE have all the db code necessary for them to work. They are calling db objects that have already been used and are not in a state to be used futher as you are calling them. It can get confusing, so what I like to do to keep things straight is use different objects for each one.  You could also use the same objects, just set different SQL based on the buttons (INSERT vs DELETE).

    What I would also do is put the showdetails code last, so if a button was pressed, showdetails will show the latest records.

    Tom Kaminski (former IIS MVP 2002-2010)
    http://mvp.support.microsoft.com/
  • Re: Please help me in my last step in my website... having 2 buttons in the same page..

    Jan 19, 2011 02:42 PM|hdhd|LINK

     I did not understand you.. can you reformat it or give me an example..

     

    Thanks..