Solved

Double Quote problem when passing Textarea values through hidden form fields

Posted on 2004-05-02
6
1,734 Views
Last Modified: 2008-03-03
Ok, I have searched all over the net for this problem and everything I read says that there's a single quote ( ' ) problem but not a double quote ( " ) problem. Mine however is.

I have a form like this:

****form.asp****
<form name="tester" method="post" action="test2.asp">
<textarea cols=60 rows=30 name="story"></textarea>
<input type="submit" value=" submit ">
</form>

Then it sends it to this page where I get textarea value and then pass it to another form through a hidden form field:

****test2.asp****
<%
uStory=TRIM(request("story"))
%>
<form name="tester2" method="post" action="test3.asp">
<input type="hidden" name="theNewStory" value="<%=uStory%>">
<input type="submit" value=" submit ">
</form>

It goes to this page where the problem occurs:

****test3.asp****
<%
nStory=TRIM(request("theNewStory"))

response.write nStory
%>

The problem is, when a user enters double quotes into the textarea like this:

Hello my name is "John" and today we will learn about cats.

Well, when that value is sent to test2.asp page, and I response.write the value, it comes through just perfect, just as it is typed above. But then when its passed through the hidden form field and onto test3.asp, when I response.write the value it shows as:

Hello my name is

So its choking on the double quotes here. Although it doesn't choke the first time. I have thought of using the replace function like:

nStory=Replace(nStory, """, """")

but you cant put a double quote inside double quotes or vbscript treats it as a set of double quotes, and then a single double quote and messes the page up.

Can someone please help me here or let me know if I am doing something wrong.

Thanks much in advance ~

webdude
0
Comment
Question by:webdude
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 31

Accepted Solution

by:
alorentz earned 125 total points
ID: 10972243
Try one of these:

****test2.asp****
<%
uStory=TRIM(request("story"))
uStory = replace(ustory, """", "''")  '<----------replace double quotes with 2 single quotes
%>
<form name="tester2" method="post" action="test3.asp">
<input type="hidden" name="theNewStory" value="<%=uStory%>">
<input type="submit" value=" submit ">
</form>
0
 
LVL 31

Expert Comment

by:alorentz
ID: 10972244
OR

****test2.asp****
<%
uStory=TRIM(request("story"))
uStory = replace(ustory, """", "`")  '<----------replace double quotes with hyphen symbol (next to number 1 on keyboard)%>
<form name="tester2" method="post" action="test3.asp">
<input type="hidden" name="theNewStory" value="<%=uStory%>">
<input type="submit" value=" submit ">
</form>
0
 

Author Comment

by:webdude
ID: 10972275
Hmm, I could see how that could work if the user entered:

Hi my name is ""Chris"" and today we will talk about cats.

Because in your Replace Function you are replacing the string ( "" ) and I need to Replace ( " ). I am goin to try it now anyways and see if I am right...be right back ~
0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
LVL 31

Expert Comment

by:alorentz
ID: 10972296
Ahhh...always the pessimist ay...   Just try it, it works fine for what you need!
0
 

Author Comment

by:webdude
ID: 10972323
hehe, I stand corrected =)

it works fine, even though I dont understand how it does. But thank you all the same

Bravo ~
0
 

Expert Comment

by:exar75
ID: 11362793
Hey Guys - additionally (if you wanna hold onto double quotes) you can use a Right Double Quotation Mark - ie:
Function quotrepl(strInput)
      newtext = replace(strinput,"""","”")
      quotrepl = newtext
End Function
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
If condition on Html with Asp 11 49
MS SQL and inserting dates into tables using stored procedures 6 45
Validating number not work with decimal 4 46
JSON Error in ASP Page 3 39
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question