Hidden field data being truncating at space

G

groupie

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

liamgegan

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.

could you post code and/or a link?
 
G

groupie

could you post code and/or a link?

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") %> >
 
L

lihao0129

could you post code and/or a link?

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") %> >

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

liamgegan

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

You need quotes around your ASP statement:
<input name="ctry" type="text" id="ctry" value= "<%
=Request("hiddenField") %>" >
 
G

groupie

On Jan 27, 10:09 pm, "(e-mail address removed)" <[email protected]>
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") %> >

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)- Hide quoted text -

- Show quoted text -

I can't believe it was that simple!

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

Thomas 'PointedEars' Lahn


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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top