One Form, Two Submits, How?

Discussion in 'Programming' started by circuscircus, Jan 28, 2007.

Thread Status:
Not open for further replies.
  1. #1
    I have one form which is a dropdown which is a list of basically images

    I want one submit to take me to the page that edits the image and the other submit for me to remove the image

    how can I implement this?
     
    circuscircus, Jan 28, 2007 IP
  2. TwistMyArm

    TwistMyArm Peon

    Messages:
    931
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Haven't done this for a while so can't provide a hard, concrete example, but I believe the way I did something similar was to:
    1) create a hidden form field
    2) add an onclick handler to the submit button/s that sets a known value into the hidden form field before actually doing the submit.

    That way the target file will be able to look at the hidden field and determine what was clicked.
     
    TwistMyArm, Jan 28, 2007 IP
  3. ccoonen

    ccoonen Well-Known Member

    Messages:
    1,606
    Likes Received:
    71
    Best Answers:
    0
    Trophy Points:
    160
    #3
    Have your Submit actually do the submitting, and have your dropdown list have an onChange event which uses javascript to redirect to another page with a querystring of this.value. Then redirect to referer. So you only need one actual submit function :)
     
    ccoonen, Jan 28, 2007 IP
  4. Barti1987

    Barti1987 Well-Known Member

    Messages:
    2,703
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    185
    #4
    Easy just create two buttons:

    submit1 and submit2

    when the form is processed check for either $_POST['submit1'] == 'whatever you named it' or $_POST['submit2'] == 'whatever you named it'.

    Edit: Since both values will be sent, you will need to check for the X/Y values (how to do that, I have no idea, but I know its how its done :D).

    Peace,
     
    Barti1987, Jan 28, 2007 IP
Thread Status:
Not open for further replies.