SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Mar 2005
    Posts
    35
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Javascript Redirect

    Javascript question
    I have a link on my website "click here to purchase" when customer clicks on it he gets a custom alert window saying 'you are going to purchase the item xyz. click on ok to proceed or cancel to cancel' The user should here point to purchase.aspx after clicking on ok. This custom alert points to different locations for different links like purchase.aspx, query.aspx etc for each page custom window. plz tell me how do I write the javascript for the same so that each time user clicks on ok he is redirected to the proper page.

    here is the sample code
    <div id="alertcustom">
    <p>'you are going to purchase the item xyz. click on ok to proceed or cancel to cancel'</p>
    <form id="form1" action="#" onsubmit="xyz();">
    <input id="OK" class="okbutton" name="OK" value="OK" type="submit" />
    <input id="Cancel" class="cancelbutton" name="Cancel" value="Cancel" type="submit" />
    </form>
    </div>

    Thanks - Vicky....

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,526
    Mentioned
    83 Post(s)
    Tagged
    3 Thread(s)
    Code HTML4Strict:
    <form id="form1" action="#" onsubmit="return confirm('Are you sure you want to purchase this item?');">

  3. #3
    SitePoint Wizard stereofrog's Avatar
    Join Date
    Apr 2004
    Location
    germany
    Posts
    4,324
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hm, you really want the customer to confirm if he's sure about purchasing something from you. You cannot be serious.

  4. #4
    SitePoint Zealot
    Join Date
    Dec 2007
    Posts
    120
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I agree, it's bad form to confirm a "click here to purchase" link. But if you must, it's just a confirm, if it returns true ("ok"), direct them to wherever, if it returns null, I think it is ("cancel"), do whatever...


Bookmarks

Posting Permissions

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