Countries in a select field

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

    Countries in a select field

    I have Countries in a drop-down list.

    Any countries with more than one word are not captured properly in form
    variables. Only the first word is captured to the variable. So, for
    instance, if 'British Virgin Islands' is selected, only 'British' is
    captured to the form variable.

    Any thoughts on why this is happening?

    Thanks,

    Scott


  • Pedro Graca

    #2
    Re: Countries in a select field

    Scott Castillo wrote:[color=blue]
    > I have Countries in a drop-down list.
    >
    > Any countries with more than one word are not captured properly in form
    > variables. Only the first word is captured to the variable. So, for
    > instance, if 'British Virgin Islands' is selected, only 'British' is
    > captured to the form variable.[/color]

    You have to surround the value with quotes

    Try this:

    #v+
    <?php
    echo <<<HTML
    <form action="" method="post">
    <select name="x">
    <option>one two three</option>
    <option value="four five six">four five six</option>
    <option value=seven eight nine>seven eight nine</option>
    </select>
    <input type="submit"/>
    </form>
    HTML;

    echo '<pre>'; print_r($_POST) ; echo '</pre>';
    ?>
    #v-
    --
    --= my mail box only accepts =--
    --= Content-Type: text/plain =--
    --= Size below 10001 bytes =--

    Comment

    • Ash Argent-Katwala

      #3
      Re: Countries in a select field

      On Thu, 26 Feb 2004, Pedro Graca wrote:[color=blue][color=green]
      >> Any countries with more than one word are not captured properly in form
      >> variables. Only the first word is captured to the variable. So, for
      >> instance, if 'British Virgin Islands' is selected, only 'British' is
      >> captured to the form variable.[/color]
      >You have to surround the value with quotes
      >Try this:[/color]
      <snip>[color=blue]
      > <option>one two three</option>
      > <option value="four five six">four five six</option>
      > <option value=seven eight nine>seven eight nine</option>[/color]
      <snip>

      Or, if you really do want to have the content of the element sent back, just
      omit the 'value' attribute on option.

      --
      ash
      a-k
      .... If she doesn't scare ya, no evil thing will...

      Comment

      • Fred H

        #4
        Re: Countries in a select field

        På Thu, 26 Feb 2004 08:06:13 -0800, skrev Scott Castillo <scasti2@cox.ne t>:
        [color=blue]
        > I have Countries in a drop-down list. (...)[/color]

        This is *so* OT. This is HTML. Ask a HTML group.

        --
        Fred H

        void FredH::Contact( ) {
        TextToSpeach.sa y("frode at age dee dee dot en oh");
        }

        Comment

        • Scott Castillo

          #5
          Re: Countries in a select field

          Thank you very much.

          "Pedro Graca" <hexkid@hotpop. com> wrote in message
          news:c1l2fg$1jf 775$1@ID-203069.news.uni-berlin.de...[color=blue]
          > Scott Castillo wrote:[color=green]
          > > I have Countries in a drop-down list.
          > >
          > > Any countries with more than one word are not captured properly in form
          > > variables. Only the first word is captured to the variable. So, for
          > > instance, if 'British Virgin Islands' is selected, only 'British' is
          > > captured to the form variable.[/color]
          >
          > You have to surround the value with quotes
          >
          > Try this:
          >
          > #v+
          > <?php
          > echo <<<HTML
          > <form action="" method="post">
          > <select name="x">
          > <option>one two three</option>
          > <option value="four five six">four five six</option>
          > <option value=seven eight nine>seven eight nine</option>
          > </select>
          > <input type="submit"/>
          > </form>
          > HTML;
          >
          > echo '<pre>'; print_r($_POST) ; echo '</pre>';
          > ?>
          > #v-
          > --
          > --= my mail box only accepts =--
          > --= Content-Type: text/plain =--
          > --= Size below 10001 bytes =--[/color]


          Comment

          • Scott Castillo

            #6
            Re: Countries in a select field

            Thank you very much.

            "Ash Argent-Katwala" <ash@videdot.co m> wrote in message
            news:Pine.LNX.4 .58.04022615180 60.32123@gauss. doc.ic.ac.uk...[color=blue]
            > On Thu, 26 Feb 2004, Pedro Graca wrote:[color=green][color=darkred]
            > >> Any countries with more than one word are not captured properly in form
            > >> variables. Only the first word is captured to the variable. So, for
            > >> instance, if 'British Virgin Islands' is selected, only 'British'[/color][/color][/color]
            is[color=blue][color=green][color=darkred]
            > >> captured to the form variable.[/color]
            > >You have to surround the value with quotes
            > >Try this:[/color]
            > <snip>[color=green]
            > > <option>one two three</option>
            > > <option value="four five six">four five six</option>
            > > <option value=seven eight nine>seven eight nine</option>[/color]
            > <snip>
            >
            > Or, if you really do want to have the content of the element sent back,[/color]
            just[color=blue]
            > omit the 'value' attribute on option.
            >
            > --
            > ash
            > a-k
            > ... If she doesn't scare ya, no evil thing will...
            >[/color]


            Comment

            • Rudolf Horbas

              #7
              Re: Countries in a select field

              Fred H wrote:
              [color=blue]
              > På Thu, 26 Feb 2004 08:06:13 -0800, skrev Scott Castillo <scasti2@cox.ne t>:
              >[color=green]
              >> I have Countries in a drop-down list. (...)[/color]
              >
              >
              > This is *so* OT. This is HTML. Ask a HTML group.[/color]

              He's not reading the variables with html, right?

              IMO form processing and creation ain't OT.

              Rudi

              Comment

              Working...