Countries in a select field – PHP

  php

Q(Question):

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

A(Answer):

Scott Castillo wrote:

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.

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 =–

A(Answer):

On Thu, 26 Feb 2004, Pedro Graca wrote:

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.You have to surround the value with quotes
Try this:

<snip> <option>one two three</option>
<option value="four five six">four five six</option>
<option value=seven eight nine>seven eight nine</option>

<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…

A(Answer):

På Thu, 26 Feb 2004 08:06:13 -0800, skrev Scott Castillo <sc*****@cox.net>:

I have Countries in a drop-down list. (…)

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


Fred H

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

A(Answer):

Thank you very much.

"Pedro Graca" <he****@hotpop.com> wrote in message
news:c1*************@ID-203069.news.uni-berlin.de…

Scott Castillo wrote:

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.

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 =–

A(Answer):

Thank you very much.

"Ash Argent-Katwala" <as*@videdot.com> wrote in message
news:Pi*******************************@gauss.doc.i c.ac.uk…

On Thu, 26 Feb 2004, Pedro Graca wrote:

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.You have to surround the value with quotes
Try this:

<snip>

<option>one two three</option>
<option value="four five six">four five six</option>
<option value=seven eight nine>seven eight nine</option>

<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…

A(Answer):

Fred H wrote:

På Thu, 26 Feb 2004 08:06:13 -0800, skrev Scott Castillo <sc*****@cox.net>:

I have Countries in a drop-down list. (…)

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

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

IMO form processing and creation ain’t OT.

Rudi

LEAVE A COMMENT