Passing value of a button thats not a Submit button

Discussion in 'ASP General' started by Lukelrc, Jun 9, 2004.

  1. Lukelrc

    Lukelrc Guest

    Hi all,

    I have an asp page with a delete button which has an OnClick Ok/Cancel
    msgbox event. My problem is that in order to run the Onclick event
    i've chaged the buttons type from "Submit" to "Button" - and now the
    buttons value (which i need in the next page) is not passed in the
    URL.

    This is what i have tried to do:

    <SCRIPT language="VBScript">
    Sub btnDelete_onClick()
    returnvalue=MsgBox ("Are you sure you want to delete this document
    from the intranet?", VBOKCancel)
    If returnvalue = 1 then
    fmPressReleaseFields.action = "report.asp?btnDelete=Delete"
    fmPressReleaseFields.submit()
    end if
    End Sub
    </SCRIPT>

    but for some reaseon the ?btnDelete=Delete part of the url is not
    passed, possibly beacuse there are other values i'm passing that are
    overwriting it(?)

    Can anyone thing of a way to pass the butons value??

    Thanks in advance.
     
    Lukelrc, Jun 9, 2004
    #1
    1. Advertising

  2. Lukelrc

    Hans Guest

    Are you reading the data from the querystring and not from the form
    collection on the server? Is fmPressReleaseFields assigned to the form?

    An alternative would be to assign the value in a hidden field instead of
    adding the value to the querystring and then submit the form.

    BTW client side VB script is only supported by IE. You will have bigger
    chance to get a crossbrowser solution if you use javascript if that matters
    for you.

    Regards
    /Hans
     
    Hans, Jun 9, 2004
    #2
    1. Advertising

  3. Lukelrc

    Luke Curtis Guest

    Cheers,

    It's an inranet asp site so i know everyone will be using IE.

    fmPressReleaseFileds is the name of the form.

    I guess i'm reading the data from thr collection on the server - i'm
    just using Request("xyz") on the next page to collect the values.

    I considered using a hidden field to pass the value, but the problem
    with that is that i have several buttons on the page (Save, Delete and
    cancel) and the hidden field would be submitted whichever button is
    pressed - which would mess up the next page.

    Maybe - is there a way to only submit the hidden field id the delete
    button is pressed? Or to set the value of the hidden field in vbscript
    OnClick event?








    *** Sent via Devdex http://www.devdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Luke Curtis, Jun 9, 2004
    #3
  4. Lukelrc

    Luke Curtis Guest

    Ah, I've just answerd my own question.

    I added hidden field in named 'hdnDelete' and also added a line to the
    OnClick event

    fmPressReleaseFeilds.hdnDelete.value = "Delete"

    Then on the next page when i say:

    If Request("btnDelte")...

    i wrote

    If Request("btnDelete") or Request("hdnDelete")...

    The answer is always much easyer than your expect!

    *** Sent via Devdex http://www.devdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Luke Curtis, Jun 9, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tom Pester
    Replies:
    0
    Views:
    388
    Tom Pester
    Oct 8, 2003
  2. Replies:
    0
    Views:
    415
  3. U. George
    Replies:
    16
    Views:
    1,242
    Andrew Thompson
    Jan 7, 2006
  4. Jonathan N. Little
    Replies:
    13
    Views:
    5,705
    Jonathan N. Little
    Feb 6, 2005
  5. Replies:
    4
    Views:
    399
    Diez B. Roggisch
    Mar 4, 2006
Loading...

Share This Page