@ Lukas && MorningZ
If you don't use jQuery for the task, you my have to assure by
yourself that the code will work under all the browsers.


On Sep 7, 1:39 am, Lukas Polak <[EMAIL PROTECTED]> wrote:
> you don't need to use jQuery. I've just been solving problem about how
> can I get value of SELECT by jQuery and I've realized that there is
> another, easier path. Just use simple JS:
> function getID()
> {
>   return  document.getElementById('test').selectedIndex; // this  
> command find out index of actually selected option}
>
> if you want to increase it or decrease it, just use simple math :)
> function Increase()
> {
>   var id = getID();
>   id++;
>   if (id > maxID) id = minID;
>   upd(id);
>
> }
>
> function Decrease()
> {
>   var id = getID();
>   id--;
>   if (id < minID) id = maxID;
>   upd(id);}
>
> and then just update text in label  - you can use simple JS as well:
> function upd(newID)
> {
> document.getElementById('the_previous_or_next_option_value').innerHTML =
> document,getElementById('test').options[newID].text;
>
> }
>
> It may works.
>
> etnas  wrote / napísal(a):
>
> > Hi!
> > Everyone knows how to manipulate the OPTIONS of a SELECT with jQuery??
>
> > I have, for example, this SELECT:
>
> > <select id="test">
> >   <option value="1">Option 1</option>
> >   <option value="2">Option 2</option>
> >   <option value="3">Option 3</option>
> > </select>
>
> > And I have 2 buttons on the document:
>
> > <input type="button" name="pre" id="pre" value="previous option" />
> > <input type="button" name="post" id="post" value="post option" />
>
> > Ok!; I need to change the selected option in the SELECT when I push
> > the 'pre' or the 'post' button and send the new value of the previous
> > or next option to a label:
>
> > <label id="the_previous_or_next_option_value"></label>
>
> > Thanks for your comments!

Reply via email to