Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Aug 2002
    Posts
    151
    Thanks
    0
    Thanked 0 Times in 0 Posts

    HTML form - 2 submit buttons going to different places?

    I've built a site for a client and there is a page which lists news stories. This is to be updated by them and I've been building a small admin area using php for this purpose.

    So I've created a form for adding a News Story to the site and has input fields for the story text and a file input box to upload an image.

    There is an "Add" (submit) button which submits the form, adds the story text to the database and stores the uploaded image in a folder (using the inserted id of that that record as the image name).

    Once the add button is clicked though, the story is up live on the site. I thought it would be good if the client could get a preview first of what the page would look like so on my form page I'd like to have a "preview"(submit) button which submits to a different preview page.

    This preview page would just display the inputted info and add the image to a temp directory.

    This is not ideal but seems to be the simplest way i can think of so far.


    so.... is it possible to have 2 submit buttons in a form both going to different places.

    Also if you have any better suggestions on a way to give the client a preview of the content they have added before it's actually live please let me know.

  • #2
    Regular Coder COBOLdinosaur's Avatar
    Join Date
    Jul 2002
    Location
    Canada
    Posts
    408
    Thanks
    2
    Thanked 32 Times in 32 Posts
    <form action="">
    all the form fields here

    <input type="button" value="Preview"
    onClick="this.form.action='previewscript.php';this.form.submit()">

    <input type="button" value="Submit"
    onClick="this.form.action='updatescript.php';this.form.submit()">
    </form>
    100% standards compliant code is 100% correct 100% of the time.
    one of my toys from my repository and perhaps some help getting help

    Cd&

  • #3
    New Coder
    Join Date
    Oct 2009
    Posts
    71
    Thanks
    16
    Thanked 0 Times in 0 Posts
    Thanks this helped me today

  • #4
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,861
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    so.... is it possible to have 2 submit buttons in a form both going to different places.
    I'd use a single page and add conditional blocks to execute the code based on which button was pressed(without any javascript code, which is not reliable in all cases).
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •