hidden fields

They have: 5,633 posts

Joined: Jan 1970

I'm using hidden fields to pass data between asp pages. When my data value is text and includes double quotes (i.e. moving to "Denver" in the summer) I lose anything after the double quotes. So I end up with: moving to.

I think this is due to the way hidden fields work:

value = requires the double quotes so it gets confused when the variable value includes double quotes.

Is there a way to handle this situation?

Larry
[email protected]

akohl's picture

They have: 117 posts

Joined: Feb 2001

You are right about the cause of the problem. But Its got nothing to do with the hidden type of input field. Any input field with behave the same way. The string value of the input field is everything between the quotes which in your case ends just before the word 'moving'.

The solution is to use "e; or " instead of actual quote marks in your string. These guys are presented on the browser as quote marks. But they aren't interpreted in your code as quote marks.

Hope this helps

Andy Kohlenberg
Jerusalem, Israel

Vincent Puglia's picture

They have: 634 posts

Joined: Dec 1999

Hi larryb,

In the case of the example you gave:

value='

<?php
=strMgrLocalMkt
?>
' -- the double quotes will remain within the single quotes

If you do not know whether the quotes are single or double you will need to call a function that inserts an escape character before each quote, something like:

function addEscape(fldValue)
{
dquote = '"';
squote = "'";
retVal = "";
for (i=0; i < fldValue.length; i++)
{
if ((fldValue.substr(i,i+1) == dquote)||(fldValue.substr(i,i+1) == squote))
retVal += "\" + fldValue.substr(i,i+1);
else
retVal += fldValue.substr(i,i+1);
}
return (retVal);
}

Vinny

Where the world once stood
the blades of grass cut me still

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.