Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8850959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:01:24+00:00 2026-06-14T13:01:24+00:00

Could someone help me out converting this into a .live click? <input class=productSubmitInput name=AddToCart_Submit

  • 0

Could someone help me out converting this into a .live click?

<input class="productSubmitInput" name="AddToCart_Submit" type="submit" value="Add to Cart" onclick="AddToCart(26483,3123041,'',4,false);return false;">

Theres an AddToCart function on the onclick I need to run with the .live jquery function and I can’t understand how to convert it

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T13:01:25+00:00Added an answer on June 14, 2026 at 1:01 pm

    Unless you are using a really old version of jQuery you should not use the .live() method at all. If using version 1.7 or later use the delegated form of .on(); if using older than 1.7 but newer than 1.4.2 use .delegate().

    $(document).on("click", ".productSubmitInput", function() { })
    

    is equivalent to

    $(".productSubmitInput").live(function() { })
    

    …except better because it is more efficient and more flexible. Ideally instead of $(document) you’d do $("#someForm") where "#someForm" is the form that your buttons are in.

    Having said that, following is one way to convert your code. I’ll assume that the arguments you pass to the AddToCart() function are specific to each button, so you’d still need to associate them with the button somehow – I’ll use data- attributes:

    <input class="productSubmitInput" name="AddToCart_Submit" type="submit"
           value="Add to Cart"
           data-param1="26483" data-param2="3123041"
           data-param3="" data-param4="4" data-param5="false">
    

    Then, having removed the inline onclick= attribute you’d do the following in a script block:

    $(document).ready(function() {
        // $(document).on("click", ".productSubmitInput", function() {
        // OR, better
        $("#yourFormIdHere").on("click", ".productSubmitInput", function() {
            var $this = $(this);
            AddToCart( $this.data("param1"), $this.data("param2"), $this.data("param3"),
                       $this.data("param4"), $this.data("param5") );
            return false;
        });
    });
    

    Of course if some of those AddToCart() parameters are the same for all buttons then you can put them directly into the JS rather than storing them as attributes in the HTML, for example if the last parameter is always false:

        AddToCart( $this.data("param1"), $this.data("param2"), $this.data("param3"),
                   $this.data("param4"), false );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi could someone help me out with this jQuery? I have: $(document).ready(function () {
Could someone help me out with the correct syntax for this query please. I
Could someone help me out with this JQuery? I have a bunch of list
Could someone help me out? it's probably something simple i'm overlooking: <script src=http://jqueryui.com/ui/jquery.ui.core.js></script> <script
I wonder if someone could help me figure out how to parse a string
could someone help me on this problem, i want to access facebook API through
Could someone help me on this, I have created simple web services using axis2
Could someone help me understand the primitive accessors with this example : i don't
Sorry for the newbie question. Could someone help me out? Simple array here. What's
hoping someone can help me out with this. I'm trying to figure out whether

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.