?
Solved

Entering HTML / XML tags in a Textarea tag

Posted on 2003-03-08
7
Medium Priority
?
325 Views
Last Modified: 2013-11-19
I am trying create an HTML form to accept XML / XSLT, and I'm having trouble getting the XML tags that people enter in the Textarea. When I submit the form, all I get is the text between the tags. For example, if someone enters: <tag>blah</tag> in the textarea, I only get "blah" when I retrieve the value of the textarea element. I am using Mason (Perl/HTML).

0
Comment
Question by:tarunsachdeva
[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
7 Comments
 
LVL 6

Accepted Solution

by:
mattjp88 earned 280 total points
ID: 8096322
<head>
<script>
function changetags() {
var text=document.frm1.text1.value;
var text1=text.split('<').join('&lt');
var text2=text1.split('>').join('&gt');
document.frm1.text1.value=text2;
//document.frm1.submit()
}
</script>
</head>
<body>
<form name=frm1>
<textarea NAME=text1></textarea><br>
<input TYPE="Button" VALUE=Submit onclick=changetags()>
</form>
</body>

matt :-)
0
 
LVL 5

Expert Comment

by:gator4life
ID: 8097100
You might want to uncomment that last line of JavaScript in the changetags() function though, if you actually want the form to be submitted! ;-)

gator4life
(chomp, chomp)
0
 
LVL 28

Expert Comment

by:sybe
ID: 8097404
I guess it is being submitted ok, but when you display <tag>blah</tag> in a browser, it will only show "blah", because HTML-tags are not displayed in a browser. Just look at the "view source" in your browser, and you'll see that everything is there.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 8097828
You better get the stings right in teh function:

var text1=text.split('<').join('&lt');
var text2=text1.split('>').join('&gt');


Should be:
var text1=text.split('<').join('&lt;');
var text2=text1.split('>').join('&gt;');


Unless you want it to display as:
&lttag&gtblah

Cd&
0
 

Author Comment

by:tarunsachdeva
ID: 8099747
Let me rephrase the question, because I'm not sure things are going to work with a Javascript based solution.

In my Mason file called "test.m", I have a form as such:

<form action=test.m method=post>
<textarea name="formdata" rows="10" cols="50"></textarea>
</form>

Later on in the file, in <%perl> blocks, I have:

<%perl>
               
my $xslt_form_result = $m->comp('form-handler.m', formdata => $form_data);

print $xslt_form_result;
</%perl>

Now, in my "form-handler.m", I try to access the formdata variable, which should have data that looks something like this (this is malformed XSLT, just written for this example):

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:template match="/">
<!--Add XSL HERE-->
<p align="left"><font color="000000">
<tr>
</tr>
<tr>
<xsl:for-each select="ProductInfo/Details">
....
<!--End of XSL-->
</xsl:template>
</xsl:stylesheet>

Now, the only thing I'm actually getting is the HTML tags, which are <p align="left">,<font>, and all that jazz. I'm not getting any of the <xsl:> tags when I try to access $formdata.

Thanks for any help.

-t
0
 
LVL 6

Expert Comment

by:mattjp88
ID: 8099769
this isnt really HTML.  some of it is but most of it is Perl.  im no good with perl.  im out.

-Matt
0
 

Author Comment

by:tarunsachdeva
ID: 8099984
Actually, I found a way around things using your solution matt. Thanks.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

718 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