[jQuery] Re: generate AJAX data based on number of select elements

2009-04-13 Thread Kinsbane

Having an issue with .serialize() - it's not grabbing the values for
the names of the elements, and it only
does it for those elements that are already on the page when it's
loaded. It's not returning in the serialized string
any of the SELECT elements that get added when someone picks a piece
of literature.

Is it really this hard to get something going? :(

On Apr 10, 10:56 am, Kinsbane kinsb...@gmail.com wrote:
 Hi Ricardo,

 Thanks! Will this serialize everything about the element with class of
 litqty? I will give it a shot.

 I'm sorry for not explaining to others in detail about what I need.
 Here it is:
 Each piece of literature that gets selected returns an ID telling us
 where to pull it from (documents or datasheets)
 and a unique alpha-numeric string called our control number. This is
 what the ID attribute and the NAME attribute in the select element
 holds.
 This is what I need to add to the reqData variable - I need the NAME
 of the ID of the select itself, along with the value of that select,
 because the ID tells us what we need to print
 out and ship.

 Thanks everyone!

 On Apr 10, 9:20 am, Ricardo ricardob...@gmail.com wrote:

  You can't return anything rom $().each, and object literals are not
  scope blocks, that won't work, it would have to be something like
  this:

  $(function() {
          //serialize() creates a query string from the form elements
  provided
          var reqData = $('.litqty').serialize();

          $(form#form_search_country).submit(function() {
                $.post('submitLitRequest.php', reqData);
                return false;
          });

  });

  On Apr 9, 5:02 pm, mattimus5...@gmail.com mattimus5...@gmail.com
  wrote:

   Ok I see your code from the above post now.

   var reqData = {
                   $('select.litqty').each(
                        $(this).attr('name') : $(this).val();
                  );
           }
   This would get the name and value of each select.litqty
   Is this what you are trying to achieve??

   On Apr 9, 3:48 pm, mattimus5...@gmail.com mattimus5...@gmail.com
   wrote:

You are just trying to get the value of the select box and only the
select box???

So you have something like
ul class=books
li Book 1 select class=litqtyoption.. //select/li???
li Book 2 select class=litqtyoption.. //select/li
li Book 3 select class=litqtyoption.. //select/li
li Book 4 select class=litqtyoption.. //select/li
/ul

 What do you need reqData to look like?


[jQuery] Re: generate AJAX data based on number of select elements

2009-04-10 Thread Ricardo

You can't return anything rom $().each, and object literals are not
scope blocks, that won't work, it would have to be something like
this:

$(function() {
//serialize() creates a query string from the form elements
provided
var reqData = $('.litqty').serialize();

$(form#form_search_country).submit(function() {
  $.post('submitLitRequest.php', reqData);
  return false;
});

});


On Apr 9, 5:02 pm, mattimus5...@gmail.com mattimus5...@gmail.com
wrote:
 Ok I see your code from the above post now.

 var reqData = {
                 $('select.litqty').each(
                      $(this).attr('name') : $(this).val();
                );
         }
 This would get the name and value of each select.litqty
 Is this what you are trying to achieve??

 On Apr 9, 3:48 pm, mattimus5...@gmail.com mattimus5...@gmail.com
 wrote:

  You are just trying to get the value of the select box and only the
  select box???

  So you have something like
  ul class=books
  li Book 1 select class=litqtyoption.. //select/li???
  li Book 2 select class=litqtyoption.. //select/li
  li Book 3 select class=litqtyoption.. //select/li
  li Book 4 select class=litqtyoption.. //select/li
  /ul

   What do you need reqData to look like?


[jQuery] Re: generate AJAX data based on number of select elements

2009-04-10 Thread Kinsbane

Hi Ricardo,

Thanks! Will this serialize everything about the element with class of
litqty? I will give it a shot.

I'm sorry for not explaining to others in detail about what I need.
Here it is:
Each piece of literature that gets selected returns an ID telling us
where to pull it from (documents or datasheets)
and a unique alpha-numeric string called our control number. This is
what the ID attribute and the NAME attribute in the select element
holds.
This is what I need to add to the reqData variable - I need the NAME
of the ID of the select itself, along with the value of that select,
because the ID tells us what we need to print
out and ship.

Thanks everyone!



On Apr 10, 9:20 am, Ricardo ricardob...@gmail.com wrote:
 You can't return anything rom $().each, and object literals are not
 scope blocks, that won't work, it would have to be something like
 this:

 $(function() {
         //serialize() creates a query string from the form elements
 provided
         var reqData = $('.litqty').serialize();

         $(form#form_search_country).submit(function() {
               $.post('submitLitRequest.php', reqData);
               return false;
         });

 });

 On Apr 9, 5:02 pm, mattimus5...@gmail.com mattimus5...@gmail.com
 wrote:

  Ok I see your code from the above post now.

  var reqData = {
                  $('select.litqty').each(
                       $(this).attr('name') : $(this).val();
                 );
          }
  This would get the name and value of each select.litqty
  Is this what you are trying to achieve??

  On Apr 9, 3:48 pm, mattimus5...@gmail.com mattimus5...@gmail.com
  wrote:

   You are just trying to get the value of the select box and only the
   select box???

   So you have something like
   ul class=books
   li Book 1 select class=litqtyoption.. //select/li???
   li Book 2 select class=litqtyoption.. //select/li
   li Book 3 select class=litqtyoption.. //select/li
   li Book 4 select class=litqtyoption.. //select/li
   /ul

    What do you need reqData to look like?


[jQuery] Re: generate AJAX data based on number of select elements

2009-04-09 Thread Kinsbane

Just hoping to see if there's a solution available.


[jQuery] Re: generate AJAX data based on number of select elements

2009-04-09 Thread mattimus5...@gmail.com

You are just trying to get the value of the select box and only the
select box???

So you have something like
ul class=books
li Book 1 select class=litqtyoption.. //select/li???
li Book 2 select class=litqtyoption.. //select/li
li Book 3 select class=litqtyoption.. //select/li
li Book 4 select class=litqtyoption.. //select/li
/ul

 What do you need reqData to look like?


[jQuery] Re: generate AJAX data based on number of select elements

2009-04-09 Thread mattimus5...@gmail.com

Ok I see your code from the above post now.

var reqData = {
$('select.litqty').each(
 $(this).attr('name') : $(this).val();
   );
}
This would get the name and value of each select.litqty
Is this what you are trying to achieve??


On Apr 9, 3:48 pm, mattimus5...@gmail.com mattimus5...@gmail.com
wrote:
 You are just trying to get the value of the select box and only the
 select box???

 So you have something like
 ul class=books
 li Book 1 select class=litqtyoption.. //select/li???
 li Book 2 select class=litqtyoption.. //select/li
 li Book 3 select class=litqtyoption.. //select/li
 li Book 4 select class=litqtyoption.. //select/li
 /ul

  What do you need reqData to look like?


[jQuery] Re: generate AJAX data based on number of select elements

2009-04-08 Thread Rick Faircloth

I don't have a solution for you, but just wanted to let you
know that I'm interested in this, as well.  I'm planning
to build a real estate search interface that works with ajax
to return results to a calling page based on search choices
made by users.

My thoughts were that I would just use various functions triggered
by the check of a certain box, or a selection in a dropdown, etc.,
and all the search parameters would be scanned for their values
with any change.  I'm afraid that could get a little processor intensive,
however, with all the constant processing and changing of parameters.

I thought perhaps some kind of acceptable delay after changes might
allow users enough time to complete their search parameter changes before
triggering an ajax request.

I don't know.  I'm just in the thinking about this stage right now, but
will need to begin designing something in the next few weeks.

But your idea of dynamically looping a group of variables based on class
sounds interesting.  Haven't thought of that before.

I'll have to check out the web2ajax you referenced.

Rick


-Original Message-
From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On
Behalf Of Kinsbane
Sent: Wednesday, April 08, 2009 8:26 PM
To: jQuery (English)
Subject: [jQuery] generate AJAX data based on number of select elements


Okay, so I've been working with the Facebook Like autosuggest thing:
http://web2ajax.fr/2008/02/03/facebook-like-jquery-and-autosuggest-search-en
gine/

I've adapted it to my system to make a request system for whatever
literature people want. They select something from the results, and a
div (within a form) gets populated with a li and a select box with the
quantity they want of that piece of literature.

So I want to send this request to the server via AJAX/AHAH/AJAH
whatever, but I don't know how to dynamically include the SELECT
element's values into the data part of the $.ajax... I thought if
maybe I did a var for the different data fields, I could just pass
that one var to the $.ajax data option, but again, I'm stuck trying to
figure out how I can loop through the select elements with classname
of litqty and add them to the data var to pass to the $.ajax
function
$(function() {
var reqData = {
$('.litqty').each(
 //do something here to add it like this:
 unique-id-or-name-of-select: value-of-select
   );
}
$(form#form_search_country).submit(function() {
$.ajax('submitLitRequest.php', {
data: reqData
}
);
});

I hope that makes sense. Thanks in advance for any help !



[jQuery] Re: generate AJAX data based on number of select elements

2009-04-08 Thread Kinsbane

Thanks for the reply Rick. I'm just barely starting to get started
with jQuery and AJAX in general, and while PHP wasn't terribly hard to
pick up,
I'm always trying to find the proper flow of logic to do things with
JavaScript.
Generally I try and find a loose example of what I want that someone
else did, and adapt it to my needs by trial and error - I always seem
to learn best that way.
But this particular thing I don't think I've seen before and I don't
know the first place to look for an example. It's pretty baffling.
My other thought was to pre-define 15 or so selects in the data stream
for the AJAX request and only include in the literature request those
select ID's that have values..
The problem there is, when a person selects a piece of literature, I'm
not looping anything so I don't think I can incrementally increase a
the ID/name of the select by 1.
Or can I?


On Apr 8, 6:48 pm, Rick Faircloth r...@whitestonemedia.com wrote:
 I don't have a solution for you, but just wanted to let you
 know that I'm interested in this, as well.  I'm planning
 to build a real estate search interface that works with ajax
 to return results to a calling page based on search choices
 made by users.

 My thoughts were that I would just use various functions triggered
 by the check of a certain box, or a selection in a dropdown, etc.,
 and all the search parameters would be scanned for their values
 with any change.  I'm afraid that could get a little processor intensive,
 however, with all the constant processing and changing of parameters.

 I thought perhaps some kind of acceptable delay after changes might
 allow users enough time to complete their search parameter changes before
 triggering an ajax request.

 I don't know.  I'm just in the thinking about this stage right now, but
 will need to begin designing something in the next few weeks.

 But your idea of dynamically looping a group of variables based on class
 sounds interesting.  Haven't thought of that before.

 I'll have to check out the web2ajax you referenced.

 Rick

 -Original Message-
 From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On

 Behalf Of Kinsbane
 Sent: Wednesday, April 08, 2009 8:26 PM
 To: jQuery (English)
 Subject: [jQuery] generate AJAX data based on number of select elements

 Okay, so I've been working with the Facebook Like autosuggest 
 thing:http://web2ajax.fr/2008/02/03/facebook-like-jquery-and-autosuggest-se...
 gine/

 I've adapted it to my system to make a request system for whatever
 literature people want. They select something from the results, and a
 div (within a form) gets populated with a li and a select box with the
 quantity they want of that piece of literature.

 So I want to send this request to the server via AJAX/AHAH/AJAH
 whatever, but I don't know how to dynamically include the SELECT
 element's values into the data part of the $.ajax... I thought if
 maybe I did a var for the different data fields, I could just pass
 that one var to the $.ajax data option, but again, I'm stuck trying to
 figure out how I can loop through the select elements with classname
 of litqty and add them to the data var to pass to the $.ajax
 function
 $(function() {
         var reqData = {
                 $('.litqty').each(
                      //do something here to add it like this:
                      unique-id-or-name-of-select: value-of-select
                );
         }
         $(form#form_search_country).submit(function() {
                 $.ajax('submitLitRequest.php', {
                         data: reqData
                 }
         );
 });

 I hope that makes sense. Thanks in advance for any help !


[jQuery] Re: generate AJAX data based on number of select elements

2009-04-08 Thread Rick Faircloth

 I don't think I can incrementally increase a
 the ID/name of the select by 1.

There are a couple of ways to do that.
Can you show me an example of the select that
you'd like to use and how the options would need
to increment?

Rick

-Original Message-
From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On
Behalf Of Kinsbane
Sent: Wednesday, April 08, 2009 11:11 PM
To: jQuery (English)
Subject: [jQuery] Re: generate AJAX data based on number of select elements


Thanks for the reply Rick. I'm just barely starting to get started
with jQuery and AJAX in general, and while PHP wasn't terribly hard to
pick up,
I'm always trying to find the proper flow of logic to do things with
JavaScript.
Generally I try and find a loose example of what I want that someone
else did, and adapt it to my needs by trial and error - I always seem
to learn best that way.
But this particular thing I don't think I've seen before and I don't
know the first place to look for an example. It's pretty baffling.
My other thought was to pre-define 15 or so selects in the data stream
for the AJAX request and only include in the literature request those
select ID's that have values..
The problem there is, when a person selects a piece of literature, I'm
not looping anything so I don't think I can incrementally increase a
the ID/name of the select by 1.
Or can I?


On Apr 8, 6:48 pm, Rick Faircloth r...@whitestonemedia.com wrote:
 I don't have a solution for you, but just wanted to let you
 know that I'm interested in this, as well.  I'm planning
 to build a real estate search interface that works with ajax
 to return results to a calling page based on search choices
 made by users.

 My thoughts were that I would just use various functions triggered
 by the check of a certain box, or a selection in a dropdown, etc.,
 and all the search parameters would be scanned for their values
 with any change.  I'm afraid that could get a little processor intensive,
 however, with all the constant processing and changing of parameters.

 I thought perhaps some kind of acceptable delay after changes might
 allow users enough time to complete their search parameter changes before
 triggering an ajax request.

 I don't know.  I'm just in the thinking about this stage right now, but
 will need to begin designing something in the next few weeks.

 But your idea of dynamically looping a group of variables based on class
 sounds interesting.  Haven't thought of that before.

 I'll have to check out the web2ajax you referenced.

 Rick

 -Original Message-
 From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On

 Behalf Of Kinsbane
 Sent: Wednesday, April 08, 2009 8:26 PM
 To: jQuery (English)
 Subject: [jQuery] generate AJAX data based on number of select elements

 Okay, so I've been working with the Facebook Like autosuggest
thing:http://web2ajax.fr/2008/02/03/facebook-like-jquery-and-autosuggest-se.
..
 gine/

 I've adapted it to my system to make a request system for whatever
 literature people want. They select something from the results, and a
 div (within a form) gets populated with a li and a select box with the
 quantity they want of that piece of literature.

 So I want to send this request to the server via AJAX/AHAH/AJAH
 whatever, but I don't know how to dynamically include the SELECT
 element's values into the data part of the $.ajax... I thought if
 maybe I did a var for the different data fields, I could just pass
 that one var to the $.ajax data option, but again, I'm stuck trying to
 figure out how I can loop through the select elements with classname
 of litqty and add them to the data var to pass to the $.ajax
 function
 $(function() {
         var reqData = {
                 $('.litqty').each(
                      //do something here to add it like this:
                      unique-id-or-name-of-select: value-of-select
                );
         }
         $(form#form_search_country).submit(function() {
                 $.ajax('submitLitRequest.php', {
                         data: reqData
                 }
         );
 });

 I hope that makes sense. Thanks in advance for any help !



[jQuery] Re: generate AJAX data based on number of select elements

2009-04-08 Thread Kinsbane

Sure can, Rick!

Here's the options var that gets created for the auto-suggest.
http://jsbin.com/enita/edit

In it, you'll see the callback function that gets fired when a user
clicks their entry after searching for something. You can see where I
built the HTML string for the list item element containing the select
element to choose a quantity, as well as a link back to the original
PDF document (haven't implemented that yet) and a brief description.

On Apr 8, 8:22 pm, Rick Faircloth r...@whitestonemedia.com wrote:
  I don't think I can incrementally increase a
  the ID/name of the select by 1.

 There are a couple of ways to do that.
 Can you show me an example of the select that
 you'd like to use and how the options would need
 to increment?

 Rick

 -Original Message-
 From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On

 Behalf Of Kinsbane
 Sent: Wednesday, April 08, 2009 11:11 PM
 To: jQuery (English)
 Subject: [jQuery] Re: generate AJAX data based on number of select elements

 Thanks for the reply Rick. I'm just barely starting to get started
 with jQuery and AJAX in general, and while PHP wasn't terribly hard to
 pick up,
 I'm always trying to find the proper flow of logic to do things with
 JavaScript.
 Generally I try and find a loose example of what I want that someone
 else did, and adapt it to my needs by trial and error - I always seem
 to learn best that way.
 But this particular thing I don't think I've seen before and I don't
 know the first place to look for an example. It's pretty baffling.
 My other thought was to pre-define 15 or so selects in the data stream
 for the AJAX request and only include in the literature request those
 select ID's that have values..
 The problem there is, when a person selects a piece of literature, I'm
 not looping anything so I don't think I can incrementally increase a
 the ID/name of the select by 1.
 Or can I?

 On Apr 8, 6:48 pm, Rick Faircloth r...@whitestonemedia.com wrote:
  I don't have a solution for you, but just wanted to let you
  know that I'm interested in this, as well.  I'm planning
  to build a real estate search interface that works with ajax
  to return results to a calling page based on search choices
  made by users.

  My thoughts were that I would just use various functions triggered
  by the check of a certain box, or a selection in a dropdown, etc.,
  and all the search parameters would be scanned for their values
  with any change.  I'm afraid that could get a little processor intensive,
  however, with all the constant processing and changing of parameters.

  I thought perhaps some kind of acceptable delay after changes might
  allow users enough time to complete their search parameter changes before
  triggering an ajax request.

  I don't know.  I'm just in the thinking about this stage right now, but
  will need to begin designing something in the next few weeks.

  But your idea of dynamically looping a group of variables based on class
  sounds interesting.  Haven't thought of that before.

  I'll have to check out the web2ajax you referenced.

  Rick

  -Original Message-
  From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On

  Behalf Of Kinsbane
  Sent: Wednesday, April 08, 2009 8:26 PM
  To: jQuery (English)
  Subject: [jQuery] generate AJAX data based on number of select elements

  Okay, so I've been working with the Facebook Like autosuggest
 thing:http://web2ajax.fr/2008/02/03/facebook-like-jquery-and-autosuggest-se.
 ..
  gine/

  I've adapted it to my system to make a request system for whatever
  literature people want. They select something from the results, and a
  div (within a form) gets populated with a li and a select box with the
  quantity they want of that piece of literature.

  So I want to send this request to the server via AJAX/AHAH/AJAH
  whatever, but I don't know how to dynamically include the SELECT
  element's values into the data part of the $.ajax... I thought if
  maybe I did a var for the different data fields, I could just pass
  that one var to the $.ajax data option, but again, I'm stuck trying to
  figure out how I can loop through the select elements with classname
  of litqty and add them to the data var to pass to the $.ajax
  function
  $(function() {
          var reqData = {
                  $('.litqty').each(
                       //do something here to add it like this:
                       unique-id-or-name-of-select: value-of-select
                 );
          }
          $(form#form_search_country).submit(function() {
                  $.ajax('submitLitRequest.php', {
                          data: reqData
                  }
          );
  });

  I hope that makes sense. Thanks in advance for any help !