Hidden field data being truncating at space

Discussion in 'Javascript' started by groupie, Jan 27, 2008.

  1. groupie

    groupie Guest

    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.
     
    groupie, Jan 27, 2008
    #1
    1. Advertising

  2. groupie

    Guest

    On Jan 28, 8:03 am, groupie <> wrote:
    > 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?
     
    , Jan 27, 2008
    #2
    1. Advertising

  3. groupie

    groupie Guest

    On Jan 27, 10:09 pm, "" <>
    wrote:
    > On Jan 28, 8:03 am, groupie <> wrote:
    >
    > > 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?


    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") %> >
     
    groupie, Jan 27, 2008
    #3
  4. groupie

    Guest

    On Jan 27, 5:27 pm, groupie <> wrote:
    > On Jan 27, 10:09 pm, "" <>
    > wrote:
    >
    > > On Jan 28, 8:03 am, groupie <> wrote:

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

    >
    > 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)
     
    , Jan 27, 2008
    #4
  5. groupie

    Guest


    > 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") %>" >
     
    , Jan 27, 2008
    #5
  6. groupie

    groupie Guest

    On Jan 27, 10:39 pm, "" <>
    wrote:
    > On Jan 27, 5:27 pm, groupie <> wrote:
    >
    >
    >
    >
    >
    > > On Jan 27, 10:09 pm, "" <>
    > > wrote:

    >
    > > > On Jan 28, 8:03 am, groupie <> wrote:

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

    >
    > > 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! :)
     
    groupie, Jan 27, 2008
    #6
  7. groupie wrote:
    > [...] "" [...] 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>
     
    Thomas 'PointedEars' Lahn, Jan 27, 2008
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Shuo Xiang

    Stack space, global space, heap space

    Shuo Xiang, Jul 9, 2003, in forum: C Programming
    Replies:
    10
    Views:
    2,955
    Bryan Bullard
    Jul 11, 2003
  2. Rick
    Replies:
    3
    Views:
    8,505
    Alexey Smirnov
    Apr 13, 2010
  3. SolarCanine
    Replies:
    2
    Views:
    326
    SolarCanine
    Sep 20, 2005
  4. Sound
    Replies:
    2
    Views:
    480
    Randy Webb
    Sep 28, 2006
  5. Atrus
    Replies:
    4
    Views:
    137
    Michael J. Ryan
    Jun 13, 2009
Loading...

Share This Page