[thelist] Send hidden data from a form

Santilal Parbhu santilal at scorpioneng.co.nz
Tue Dec 30 14:49:25 CST 2008

Thank you Benjamin,

Here is the code I used.  I didn't tell you the full story before as I was
trying to present the bones of the problem only.  The option values are
actually read from a mysql database.  Maybe the problem is in how mysql
outputs the data, but I haven't managed to find any info about this.

//Print out drop-down list of all teams.  Identify the team chosen.  It will
//be contained in HTTP_POST_VARS['team_name'].
	print '<p>Select Team: <select name="team"></p>';
	$query = "SELECT DISTINCT teams_id, team_name FROM
$compteams ORDER BY team_name
	if (@mysql_query($query)) {
		$r= mysql_query($query);
		while ($row = mysql_fetch_row($r)) {
			print "<option value=$team_name>";
			print "$team_name</option>";
		<input type="submit" name="selection_made" value="Use this
team!" id="submitbutton" />
		//Query not successful.
		print "<p>Could not retrieve the entry because: <b>" .
mysql_error() . "</b>. The query was $query.</p>";

I have now changed the script so that $team_id is sent and this works ok.  

Thanks again.


-----Original Message-----
From: thelist-bounces at lists.evolt.org
[mailto:thelist-bounces at lists.evolt.org] On Behalf Of Benjamin Hawkes-Lewis
Sent: Wednesday, 31 December 2008 12:18 a.m.
To: thelist at lists.evolt.org
Subject: Re: [thelist] Send hidden data from a form

On 30/12/08 03:06, Santilal Parbhu wrote:
> I am trying to overcome a problem where the data received from an HTML
> menu is being truncated when a space is seen.  For example, if the option
> value of Red Sox is sent, it is truncated to Red.
> I have not been able to find an answer to this for over a year now.  I
> thought that another way to tackle this would be to send a hidden code
> each option value: for example; Red Sox, Code = 123, Blue Sox, Code  = 124
> etc.

There's nothing wrong with using numeric codes (and it might be better 
for internationalization reasons). But it shouldn't be necessary.

<option value="Red Sox">Red Sox</option> should work fine.


Possible problems include:

1. Mismatch of encodings producing corruption of data.
2. Some other error in your form submission processing script.

I'd be interested to see an example of a simple script showing the 
problem you've been having.

Here's a simple test case (saved and served as UTF-8) that demonstrates 
that spaces in option values work fine (tested in Firefox 3 Mac and IE6).


Benjamin Hawkes-Lewis

* * Please support the community that supports you.  * *

For unsubscribe and other options, including the Tip Harvester 
and archives of thelist go to: http://lists.evolt.org 
Workers of the Web, evolt ! 

More information about the thelist mailing list