[jQuery] Select multiple elements with "almost" same id
Hallo everyone. My name is Gjoko Pargo. I am a new member of this
group, in fact - this is my first message here. I work mainly as a web
applications developer and have extensive experience in php, asp,
coldfusion, javascript and several types of databases.
Although I do have some pretty good experience in JavaScript I still
can't seem to get the grasp of some of the jQuery concepts. So I have
two pretty basic questions which I was not able to find answers for.
1. In one of my projects, I am building a shopping cart. The product
list quantity fields are made of input fields with id's consisted of a
reserved word and product_id combination. They look something like
this:
<input type="text" name="quantity[]" id="quantity[23]" />
<input type="text" name="quantity[]" id="quantity[563]" />
For those with web application experience the name quantity with it's
two square brackets gives the browser the ability to make a list of
each entry in one associative array and send it to the browser on
submit.
My problem is - I need to select all of the form elements which have
"quantity[something]" in their id and then apply some action to them.
Could anyone please help me on how to achieve this? Is this done with
regular expressions or is there some "native" jQuery way to do this?
2. On the same page where the product list is, there is also a
shopping basket. What happens is that after the visitor populates the
quantities of the desired products he/she hits on the submit button,
and if everything is ok, the data is transfered to the server over
ajax submit and then the contents of the shopping basket is changed in
real time. Everything works ok, but I would like to add some eye
candy...
Namely, after submit, I want to fadeOut the shopping basket (or a
specific element), and then do a fedeIn to make the shopping basket
visible again with the new value. I was able to succeed in this, but
unfortunately the fedeOut, changeOfQuantityValue and fadeIn are not
synchronized. This means that depending on the speed of the connection
the list starts to fade out, changes the item list values (while still
visible), and then fades back in... or for slower connections: it
fades out, fades in and then change the item list values.
Any help with this?
Thank you very much,
Gjoko Pargo.