Thanks Ricardo, You are wonderful are understanding my problem.

After trying your code. The append part works, but the selection part
does not.

Any suggestions? Thanks for your help, I'm fairly new to jquery.

// Code does not work...? hmm

  $(".myButtons").click(function(){
     $(this).find('select').val(1); //this will select the option
with
        value == 1
  });
 });


On Feb 24, 11:25 pm, ricardobeat <ricardob...@gmail.com> wrote:
> Probably changing
>
>   $("tr #button").click(function(){...
>
> to this
>
>   $("tr #button").click(function(){
>       $("select", this).html("<option>0</option><option
> selected='selected'>1</
> option><option>2</option><option>3</option><option>4</
> option><option>5</option>");
>        return false;
>       });
>
> Will fix it. You need to find the select element in the right context,
> remember that jQuery's selectors work like CSS.
>
> Also I would write your code like this (you don't need to rewrite all
> the options just to select one, and you're not setting the option's
> values):
>
> $(document).ready(function(){
>
>   $("select").empty().append(
>        new Option(0),
>        new Option(1),
>        new Option(2)
>    );
>
>   $(".myButtons").click(function(){
>      $(this).find('select').val(1); //this will select the option with
> value == 1
>   });
>
>  });
>
> From the code your posted one can assume you have multiple elements
> with the "button" ID. That's invalid (IDs should be unique) and will
> certainly cause you trouble, use class="something" instead.
>
> cheers,
> - ricardo
>
> On Feb 23, 9:30 pm, Jsudesign <jus...@jsudesign.com> wrote:
>
> > Hi everyone,
>
> > I have an add button set up and when you click it it changes the
> > selected input from 0 to 1.
> > Where my problem is...is that it's doing this for every product.
>
> > Here's an example:http://rickyscentralcitymall.com/ordering/tables.html
>
> > I would add a new class to each product, but that's going to be a pain
> > in the end because there are 100+ items on the menu.
>
> > Here's the code I'm working with currently.
>
> > $(document).ready(function(){
> > $("select").html("<option>0</option><option>1</option><option>2</
> > option><option>3</option><option>4</option><option>5</option>");
> >         $("tr #button").click(function(){
> >                         $("select").html("<option>0</option><option 
> > selected='selected'>1</
> > option><option>2</option><option>3</option><option>4</
> > option><option>5</option>");
> >                         return false;
> >                         });
>
> >  });
>
> > Any help with this would be great.
>
> > Best,
> > Justin

Reply via email to