Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Hidden field data being truncating at space

50 views
Skip to first unread message

groupie

unread,
Jan 27, 2008, 4:03:48 PM1/27/08
to
Hi,
I'm placing data into hidden fields for passing between forms, but
after clicking submit button, the data is getting truncated at the
space,e.g. "hello world" is getting displayed as "hello" on the next
form. If I use ordinary text fields, it works fine. Any ideas what's
wrong/how to fix? Thanks.

liam...@gmail.com

unread,
Jan 27, 2008, 5:09:56 PM1/27/08
to

could you post code and/or a link?

groupie

unread,
Jan 27, 2008, 5:27:49 PM1/27/08
to
On Jan 27, 10:09 pm, "liamge...@gmail.com" <liamge...@gmail.com>
wrote:

Here's an excerpt - data picked from from combobox CTRY and javascript
function HDNCTRY saves the data into the hidden field. I put an ALERT
statement into it and it displayed the value "United States" (with
spaces). However in the destination form, I only get "United".

function hdnctry(cbobox) {
var col = (cbobox.options[cbobox.selectedIndex].text);
document.forms.additem.hiddenField.value = col;
}

<select name="ctry" onChange="hdnctry(this);">
<option value="">Choose a Country </option>
<option value="GBR">United States</option>
</select>
<input name="hiddenField" type="hidden" /></td>

Destination form:
<td width="181">Country</td>
<input name="ctry" type="text" id="ctry" value= <%
=Request("hiddenField") %> >

liha...@gmail.com

unread,
Jan 27, 2008, 5:39:29 PM1/27/08
to

A fast look shows that you probably need to add quotation marks around
the above PHP block

<input name="ctry" type="text" id="ctry" value="<%
=Request("hiddenField") %>" >

lihao(XC)

liam...@gmail.com

unread,
Jan 27, 2008, 5:45:04 PM1/27/08
to

> Destination form:
> <td width="181">Country</td>
> <input name="ctry" type="text" id="ctry" value= <%
> =Request("hiddenField") %> >

You need quotes around your ASP statement:

groupie

unread,
Jan 27, 2008, 5:47:01 PM1/27/08
to
On Jan 27, 10:39 pm, "lihao0...@gmail.com" <lihao0...@gmail.com>
wrote:
> lihao(XC)- Hide quoted text -
>
> - Show quoted text -

I can't believe it was that simple!

Thank-you very much. Works fine now! :-)

Thomas 'PointedEars' Lahn

unread,
Jan 27, 2008, 6:55:23 PM1/27/08
to
groupie wrote:
> [...] "lihao0...@gmail.com" [...] wrote:

>> [...] groupie [...] wrote:
>>> <input name="ctry" type="text" id="ctry" value= <%
>>> =Request("hiddenField") %> >
>> A fast look shows that you probably need to add quotation marks around
>> the above PHP block

It's _ASP_, unless the OP has enabled ASP-style tags in their php.ini.

>> <input name="ctry" type="text" id="ctry" value="<%
>> =Request("hiddenField") %>" >
>>

>> [...]

Please trim your quotes.

> I can't believe it was that simple!
>
> Thank-you very much. Works fine now! :-)

It is insufficient, though. You have to escape all double quotes in
Request("hiddenField") or you will end up with invalid HTML again.
In its simplest form, assuming that you are indeed using ASP:

<%@ LANGUAGE = "JScript" %>
<input name="ctry" id="ctry" value="<%
= Request("hiddenField").replace(/"/g, "&quot;")
%>">

BTW, validation would probably have revealed your previous problem, see
also http://diveintomark.org/archives/2003/05/05/why_we_wont_help_you

Also never post server-side code when you have a client-side problem,
unless someone who replies then asks you about it.


PointedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm>

0 new messages