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

  • Home
  • SEARCH
  • 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 9234655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:50:28+00:00 2026-06-18T06:50:28+00:00

I couldn’t find anything, but I feel like it’s been asked before. I have

  • 0

I couldn’t find anything, but I feel like it’s been asked before.

I have multiple inputs:

<input id="id1" class="abc" name="tags" "value="test1" />
<input id="id2" class="abc" name="tags" "value="test2" />

When the user changes the value of the input, I want the script to pick it up and assign it into an array.

What I have:

jQuery('.abc').change(function() {
        var id = jQuery(this).attr('id');
        var name = jQuery(this).attr('name');
        var value = jQuery(this).val();
        var ch = {};
        ch[id][name] = value;
        alert(ch[id][name]);
    });

But from the start, it didn’t work. jQuery(this).attr('id') doesn’t exist as a function. I think the reason this isn’t working is because there isn’t a specific class I am calling, but I don’t know. Maybe I’ve been staring at code too much, but it’s not working!

the error: can't convert undefined to object

  • 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-18T06:50:29+00:00Added an answer on June 18, 2026 at 6:50 am

    You need to create a new object for ch[id]

    jQuery('.abc').change(function () {
      var id = jQuery(this).attr('id');
      var name = jQuery(this).attr('name');
      var value = jQuery(this).val();
      var ch = {};
      ch[id] = {}; // <-- here
      ch[id][name] = value;
      alert(ch[id][name]);
    });
    

    http://jsfiddle.net/tq2CJ/

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

Sidebar

Related Questions

I couldn't find anything similar to this anywhere. I have an array of pointers
I couldn't find anything on this, but probably its just because I don't know
Couldn't find anything about this topic. I have a Windows TCP C++ server application
Couldn't find anything quite what I was looking for but if I've missed something
Couldn't find anything in the github documentation and also here on SO. But I
I couldn't really find this in Rails documentation but it seems like 'mattr_accessor' is
I couldn't find this in the documentation. If I have a complex object in
Couldn't find an answer to this anywhere, but essentially I am wanting to add
Couldn't find anything on this with a Google Search. Does anyone know how to
Couldn't find anything related to the subject in Zend Framework API. What is the

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.