Hi,
Below is a working code.

1. if($('input[name="test"]').is(":checked"))
   2. {
   3. // my other code
   4. }

I want to remove "test" and put a variable there instead

I tried this way but it does not seem to work. I am not sure where I am going wrong. Any help will be highly appreciated.

1. newData="test";
   2. if($('input[name=$(newData)]').is(":checked"))
   3. {
   4. // my other code
   5. }
newData="test";
if($('input[name="' + newData + '"]').is(":checked"))
{
 // my other code
}

Thanks hielo I cud not figure this out for an entire day. Just to show how weak I am at this.

Glad to help.

Regards,
Hielo

PS: Don't forget to mark the thread as solved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.