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 2 of 2
  1. #1
    New Coder
    Join Date
    May 2007
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Multiple Function Href

    I would like to do multiple functions on one onclick, then go to a new page.
    Here is my attempt using one function to do two things. Suggestions please

    <SCRIPT language="JavaScript">
    function submitform()
    {
    document.form.submit();
    default_b.php?action=add_item&id=<?php echo $row["id"]; ?>&qty=1">
    }
    </SCRIPT>
    </head>

    <body>
    <form name="form" action="">
    <input type='checkbox' name='chk'>

    </form>
    <A href="#" onClick=" submitform();return false;">Add Item</A>

  • #2
    New Coder
    Join Date
    Apr 2007
    Location
    Silicon Valley California
    Posts
    71
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I'm not really sure what the question is. I'll tell you what your code does though. When you click the anchor, it will go to your function and submit the form, which will POST to the current page. Never executing this mysterious line

    Code:
    default_b.php?action=add_item&id=<?php echo $row["id"]; ?>&qty=1">
    I assume this is some kind of link you want to forward the browser to. As it is written, you'll need to use AJAX to save the form, instead (plenty of online tutorials available for AJAX) and window.location = "your uri"; after the AJAX call.

    However, it would be much simpler, if you use PHP code wherever you process the form submission, to forward to the next page instead.


  •  

    Posting Permissions

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