input type=hidden

I have a string, composed of part of a SQL query, which I need to preserve by writing it to the HTML page.  I don't want the client to see the data in it, therefore Hidden.  The problem is, I don't seem to get anything but the first word of the string.  Here's the code, generated from VB IIS:

Response.Write "<input type=""Hidden"" size=""75"" name=""garbage"" value=" & strg2 & ">"

When I display this field it contains the first word of the string instead of the complete string.  I can write the same string to a list box and it works except that I find no way to hide it.
MJTaylorAsked:
Who is Participating?
 
anyanickyConnect With a Mentor Commented:
I suggested in my comment that you can hide your listbox (or textarea or whatever) - textarea will allow your quotes, double quotes etc and retain the format to the next page.  Did you try this?
0
 
thunderchickenCommented:
Even if it's a hidden input type, users can still access what's in the hidden input type by viewing the source of the html document.  I would just save it as a text file, then access it using ASP.  I've been using response.write in ASP so I assume that's what you are using too.
0
 
CJ_SCommented:
I woudn't set a size there, because who knows how long the query will be. second.

I suppose you got the strg2 out of the request("query")-method????? That should work......

or try
<input type=hidden name=garbage value=<%=request.form("thequery")%>>

it really should work....

Maybe you have to get rid of the CHR(13) and CHR(10) first....so, you might have to do:

strg = request.form("thequery")
strg = replace(strg, chr(13) & chr(10), " ")
response.write "<input type=hidden name=garbage value='" & strg & "'>"

Good luck,
CJ
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

 
mberumenCommented:
MJTaylor: you need to use the Server.Urlencode function of ASP to ensure that the complete string is passed on to the next page.

Response.Write "<input type=" "Hidden" " size=" "75" " name=""garbage"" value=' " & server.urlencode(strg2)  & " '>"

This code should preserve the full string of the variable you want to pass in your form.

The reason that you are getting an incomplete string is because the form is truncating the string when it finds the first space

regards

mberumen
0
 
MJTaylorAuthor Commented:
To thunderchicken:
I am generating the HTML out of Visual Basic IIS app, so the code isn't visible.  I don't care about that, I just don't want it displayed on the screen.

To C)_S:
You're right about the size.  I build the query on the fly using a bunch of input parameters on the original screen and put the records out in a table. If there are more records than comfortably fit on one screen, I stop execution after writing end of table,form etc.  I put a button at the bottom labeled more.  If the user clicks this button I don't want to go through the whole selection process again, so I write the query to the page and use it as input when the more is clicked.  Therefore, I can't take the spaces out.
I'm very new to HTML and don't understand what happens with the code you suggested, value=<%=request.form("thequery")%>>
0
 
mberumenCommented:
MJTaylor:

Have you tried my suggestion?.. It will work

:)

Manuel
0
 
MJTaylorAuthor Commented:
to mberumen:
I'm just about to....will let you know in a few...Thanks
0
 
MJTaylorAuthor Commented:
Well, it replaced all the spaces in my query with + signs and %27 and %28, which caused Access to puke up an error 3075, invalid query.  Any suggestions?
0
 
mberumenCommented:
i always miss the easy answer

just enclose your variable in aphostrophes!!!

Response.Write "<input type=""Hidden"" size=""75"" name=""garbage"" value='" & strg2 & "'>"

server.urlencode is used to pass string variables as part of the URL, for your form the above code should work

mberumen
0
 
MJTaylorAuthor Commented:
Well, I got the first one working by parsing the string after reading it back as input, and replacing the %28 with ( the %26 with & etc.  I think your second suggestion is much simpler and would probably work great if I weren't passing single quotes to Access as part of the string.  Do you know of another character that I can use as a delimiter instead of single quote, but not *, &, ", (, or ) as these characters sometimes make up part of the string?
0
 
CJ_SCommented:
well, you can use double quotes!!!!!!!!

like ""

this will be seen as one quote, and won't be seen as the end of the string.
0
 
nettromCommented:
I don't understand why URLencoding the string is of any use, the browser does that when it submits the form anyway, so it's just a bunch of redundancy.
0
 
anyanickyCommented:
you can hide any form element using css

<textarea name=garbage style="display:none">"hello"</textarea>
0
 
mberumenCommented:
nettrom:

I agree, I should've never brought URLencoding up!!

MTaylor:

Perhaps you should try embedding the value in HTML an enclose with double quotes
%>
<input type="Hidden" size="75" name="garbage" value="<%=strg2%>">
<%

when you use request response to get the value it should display properly

<%
strSQL=request("garbage")

%>
0
 
MJTaylorAuthor Commented:
O.K., guys, I really appreciate all the help.  So far, the only thing that works is using the URLencode and then converting the string after it's read back. The string, strg2, looks like this typically: WHERE Surveysec Like ('Mission') AND Component Like("*"&'Warhead'&"*")  This gets concatenated to the end of the search parameters in code.  As I said, it works using URLencode.  Using single or double quotes won't work because they're part of the string, I think.  That's why I asked if you knew of any other delimiters besides quote and doublequote.
0
 
freshmeatCommented:
Response.Write "<input type=""Hidden"" size=""75"" name=""garbage"" value=""" & strg2 & """>"

0
 
MJTaylorAuthor Commented:
Thanks, but this won't work because the string stops at the first double quote it finds after the left paren.
0
 
MJTaylorAuthor Commented:
To anyanicky - Yes I tried it and it works.  It's also useful in that you can turn it on and off to check whether string is being built correctly.  Thank you.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.