Next value

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • zek2005

    #1

    Next value

    Hi!!!

    I've made a form with a 'select' statement through a

    echo('<select name="res">');
    echo('<option selected value=""> Select option</option>");');
    while($row = mysql_fetch_arr ay($resumen))
    {
    echo('<option value="' .$row[id]. '">'
    ..strtoupper($r ow[titulo_esp]). '</option>');
    }
    echo('</select>');

    The user selects an option and a text is displayed. Now, I want to
    insert a "previous" and a "next" button so the user can navigate from
    here without selecting any other value from the "select" form.

    Example: The posible 'id' values are: 1,4,5,7,8,9. The user chooses 5,
    so if he press the "next" button he will navigate to the page with the
    id#7 and if the user selects "previous" he will go to the id#4.

    I tried to use the funtion next(), but I don't know how to do it.

    Can anyone help me with this problem?

    Thanks in advance!

    Ezequiel

  • Carl Vondrick

    #2
    Re: Next value

    zek2005 wrote:[color=blue]
    > Hi!!!
    >
    > I've made a form with a 'select' statement through a
    >
    > echo('<select name="res">');
    > echo('<option selected value=""> Select option</option>");');
    > while($row = mysql_fetch_arr ay($resumen))
    > {
    > echo('<option value="' .$row[id]. '">'
    > .strtoupper($ro w[titulo_esp]). '</option>');
    > }
    > echo('</select>');
    >
    > The user selects an option and a text is displayed. Now, I want to
    > insert a "previous" and a "next" button so the user can navigate from
    > here without selecting any other value from the "select" form.
    >
    > Example: The posible 'id' values are: 1,4,5,7,8,9. The user chooses 5,
    > so if he press the "next" button he will navigate to the page with the
    > id#7 and if the user selects "previous" he will go to the id#4.
    >
    > I tried to use the funtion next(), but I don't know how to do it.
    >
    > Can anyone help me with this problem?
    >
    > Thanks in advance!
    >
    > Ezequiel
    >[/color]
    You should really do this with JavaScript. PHP could do it, but it
    would be really slow.

    next() is for arrays only, which advances the array internal pointer.

    To go about this using JavaScript:
    - Give each element an sequential ID.
    - On the press of next, select current id + 1 (using dom).

    --


    Carl Vondrick
    usenet@carlsoft .net
    Professor of Computer Science at Columbia University, researching computer vision, machine learning, and AI applications.

    Comment

    • Jim Michaels

      #3
      Re: Next value


      "zek2005" <esapoznik@gmai l.com> wrote in message
      news:1138672335 .972789.176090@ g43g2000cwa.goo glegroups.com.. .[color=blue]
      > Hi!!!
      >
      > I've made a form with a 'select' statement through a
      >
      > echo('<select name="res">');
      > echo('<option selected value=""> Select option</option>");');[/color]

      you should fix this. spurious characters between options will cause wierd
      things to happen in some browsers.

      echo('<option selected value=""> Select option</option>');

      [color=blue]
      > while($row = mysql_fetch_arr ay($resumen))
      > {
      > echo('<option value="' .$row[id]. '">'[/color]

      and use quotes an an array index when using it in a function.

      ..strtoupper($r ow['titulo_esp']). '</option>');


      [color=blue]
      > }
      > echo('</select>');
      >
      > The user selects an option and a text is displayed. Now, I want to
      > insert a "previous" and a "next" button so the user can navigate from
      > here without selecting any other value from the "select" form.
      >
      > Example: The posible 'id' values are: 1,4,5,7,8,9. The user chooses 5,
      > so if he press the "next" button he will navigate to the page with the
      > id#7 and if the user selects "previous" he will go to the id#4.
      >
      > I tried to use the funtion next(), but I don't know how to do it.
      >
      > Can anyone help me with this problem?
      >
      > Thanks in advance!
      >
      > Ezequiel
      >[/color]


      Comment

      Working...