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 6774981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:51:09+00:00 2026-05-26T15:51:09+00:00

I have an img that when clicked, points to a form using a custom

  • 0

I have an img that when clicked, points to a form using a custom attribute, and that form then submits it’s hidden inputs via .post

Here is the code:

$("img.imgsubmit").live('click',function(){
    var msg = $(this).attr('title');
    var r=confirm(msg+'?');
    if (r==false){return false;}
    var form = '#'+$(this).attr('imgsubmit');
    var url = $(form).attr('action');
    var output = OutputName($(form).attr('output'));
    $("#"+output).html('<img src="images/ajax-loader.gif" alt="Working..." />');
    // get post values
    var data = {}; // define data object
    $(':input',this).each(function(index){
            alert(this); // NEVER HAPPENS
            var key = $(this).attr('name');
            var val = $(this).val();
            data[key] = val;
    });
    // post
    $.post(url,data, function(html) {
            $("#"+output).html(html).slideFadeShow("fast");
    });
    return false;
});

So everything is fine until:

$(':input',form).each(function(index){
        alert(this); // NEVER HAPPENS, so it's never finding all the inputs
        var key = $(this).attr('name');
        var val = $(this).val();
        data[key] = val;
});

I’ve tried all sorts of things with that first line:

$(':input',$(form)).each(function(index){

$(':input',form).each(function(index){

$(form+' :input').each(function(index){

None of it gets it to work. Basically, it’s not working with the object at all to select the hidden inputs inside the form element.

tl;dr everything is fine except the :input selector not working when accessing the form var.

  • 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-05-26T15:51:10+00:00Added an answer on May 26, 2026 at 3:51 pm

    Just a stab in the dark without seeing your markup but $(“form :input”) should work.

    note that it’s all in quotes

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have code that loads a bunch of images into hidden img elements and
I have an img tag in my webapp that uses the onload handler to
I have some javascript code that creates an img tag with a mouseover callback,
I have written code that automatically creates CSS sprites based on the IMG tags
I have a string that is HTML encoded: '''&lt;img class=&quot;size-medium wp-image-113&quot;\ style=&quot;margin-left: 15px;&quot; title=&quot;su1&quot;\
I have a code that looks like this: <div id=wrapper> <img id=first class=images src=img/nike.jpg
I have an anchor element that looks like this <a href=url><img src=imgurl/>Text</a> I would
I have several unordered lists that I want to display like this: <ul> <li><img></li>
I have an ASP.Net page that contains a <div> with an <img> tag within.
I have a little tool on a web page that can be clicked and

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.