473,395 Members | 1,936 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

accessing the input elements with array names in jquery

omerbutt
638 512MB
hi i have a problem i was using version 1.3 for jquery and i upgraded it to 1.8 and suddenly my code became buggy , i had 2 radio inputs with the name representative_select[]
Expand|Select|Wrap|Line Numbers
  1. <input name="representative_select[]" type="radio"  />
  2.  
and i need to check that if any one of these radio buttons is selected or not my previous working code was
Expand|Select|Wrap|Line Numbers
  1. if(jQuery("input:radio[name=payment_option[]]:checked").length==0){
  2.         str+='Please Select a Payment option\n';
  3.     }
  4.  
and after upgrade i starting receiving syntax error i did some R&D and found that some functions are deprecated in the version 1.6+, so i changed it to the following but still no use as the square brackets need to be escaped so the \\ are used but still i am not doing it right here it is

Expand|Select|Wrap|Line Numbers
  1. if(jQuery(name="representative_select\\[\\]").prop('checked').length==0){
  2.         str+='\Select a Representative option';
  3.     }
  4.  
then i gave an id to the same input id='single_rep'
and then run these two statements
Expand|Select|Wrap|Line Numbers
  1. alert(jQuery("#single_rep"));
  2. alert(jQuery(name="representative_select\\[\\]"))
  3.  
both of these statements alerted [object object]
but when i append the prop() function with the 2 statements
Expand|Select|Wrap|Line Numbers
  1. jQuery(name="representative_select\\[\\]").prop('checked')
  2. jQuery("#single_rep").prop('checked')
  3.  
the first one says that prop is undefined and the second statement alerts true /false depending on the radio being checked or un-checked

can somebody help me in this regard that what do i need to do
Jan 9 '13 #1
4 8277
Anas Mosaad
185 128KB
A silly question! Why do you put [] in the name for a radio button?
Jan 9 '13 #2
omerbutt
638 512MB
if you cant give a solution do not reply ANAS , do have some respect for other around the community, if you could have understood what i said then it would have been a lot better, a silly question is what you replied
Why do you put [] in the name for a radio button?
we can put [] with any type of input's name if we want to collect all of those input values into an array when posting on another page so please if you cant help dont be a DUMB ASS
regards,
Omer Aslam
Jan 10 '13 #3
Anas Mosaad
185 128KB
Although I thought it was a silly question, you didn't get the point I wanted you to get. Having an array of values for any input type makes sense except for radio buttons -you have only one value selected. Do you agree with me on that?

Regarding your point of respect, I think you need to learn how to respect others before you ask them to respect you. A community is not aimed for only answering your solutions. What you are asking for is a narcissistic community.
When someone asks you a question respond to him with all the respect you want others to show you.

Although I don't want to respond to you, I will through this feeling away now and tell you how to implement this if you still have a need:
Expand|Select|Wrap|Line Numbers
  1. if($("[name='representative_select[]']:checked").length==0){
  2.     alert('Select a Representative option');
  3. }
  4.  
Please let me know if you need further clarifications.
Jan 10 '13 #4
omerbutt
638 512MB
Go away man i dont need your HELP , you still writing the code that wont work for 1.6+ jquery versions go check your code with version 1.8.2 , but thanks alot, and please dont respond on this thread , i am here from the last couple of years and never came across any such discussion , although i do come across alot of people who are new bees to development and dont have their concepts clear but have never responded like this , if you know some thing please dont be proud on it , cause once you didnt knew.
take care.
Jan 11 '13 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: KathyB | last post by:
Sorry this is a bit of a repost because I wasn't quite accurate in my original. I have an hmtl page with a function to see if there are any input type=text boxes. If so, that means a user did...
3
by: Csaba Gabor | last post by:
I just someone can confirm what I observe experimentally: Input elements without names (but with an id) are not sent to the server when the form is submitted. This would be useful because I have...
2
by: Peter Wright | last post by:
Hi all. Hopefully this should demonstrate the problem I'm having: http://flooble.net/~pete/focus-problem-demo/ (I'm testing it in Mozilla only, but I'm not sure if it's actually a...
6
by: Vikram | last post by:
I have added some input elements on a page using javascript at client side. when i submit the page, i am unable to access the values of input elements created using request.form. Are elements...
10
by: tony | last post by:
i'm trying to itterate through an array that contains the names of the global arrays eg: $myarray = array("\$_GET", "\$_SERVER"); and so on The problem Im having is calling a function...
18
by: Diogenes | last post by:
Hi All; I, like others, have been frustrated with designing forms that look and flow the same in both IE and Firefox. They simply did not scale the same. I have discovered, to my chagrin,...
2
by: ewosch | last post by:
Hallo, I have a form with russion description of input elements (using utf-8), to be typed in with a russion keyboard. In the input elements should only latin-1 be possible. Is there a way to to...
0
by: yawnmoth | last post by:
I'm trying to get a list of all the input elements of a form tag and am having some difficulty doing so. First, here's my XHTML: <div> <form action=""> <input type="text" name="a" /> </div>...
5
by: yawnmoth | last post by:
I'm trying to get a list of all the input elements of a form tag and am having some difficulty doing so. First, here's my XHTML: <div> <form action=""> <input type="text" name="a" /> </div>...
4
by: rm84 | last post by:
# include <iostream> using namespace std; int main (void) { int arr,*arrf; arrf=arr+5; cout<<arr<<endl<<arrf<<endl; for(;arr<=arrf;arr=arr+1) {
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.