[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)) {
			$team_id=$row[0];
			$team_name=$row[1];
			print "<option value=$team_name>";
			print "$team_name</option>";
			}
		print'</select>
		<input type="submit" name="selection_made" value="Use this
team!" id="submitbutton" />
		</form></div>';
		}
	else{
				
		//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.

Santilal

-----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
form
> 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
with
> 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.

http://www.w3.org/TR/html401/interact/forms.html#adef-value-OPTION

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).

http://paste-bin.com/view/2ecbfbc2

--
Benjamin Hawkes-Lewis
-- 

* * Please support the community that supports you.  * *
http://evolt.org/help_support_evolt/

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