?
Solved

Handeling <LI> from the database

Posted on 2004-04-15
12
Medium Priority
?
317 Views
Last Modified: 2010-04-01
Hello Expert,
I am getting the body of a story from the database and it looks like this

This is a great story
<li> Testing this story</li>
<li> Testing Two</li>
<li> Testing three </li>

I would like to change everything that is in the <li>Testing this story </li> to dipsplay in my text are as
This is a great story
• Testing this story
• Testing Two
• Testing three
Is there anyway to do this?
Thanks
0
Comment
Question by:jvoros1
  • 4
  • 3
  • 3
  • +1
12 Comments
 
LVL 9

Expert Comment

by:Nick_72
ID: 10834165
I'm not sure I understand...you have this text in a variable, and if you print out that variable in your html, you don't get it formatted?
Can you show how your code looks now?
0
 

Author Comment

by:jvoros1
ID: 10834295
I hope this helps and in the body this is what is stored
This is a great story
<li> Testing this story</li>
<li> Testing Two</li>
<li> Testing three </li>
and i want it to look like
This is a great story
• Testing this story
• Testing Two
• Testing three
Object[] search_results = (Object[])request.getAttribute("search_results");
                  
                  for (int x = 0; x < search_results.length; x++)                            
                  {              
                        HashMap search_result = (HashMap)search_results[x];
                        
                                 String EventID = (String) search_result.get("EventID");
                              String Body =  (String) search_result.get("Body");
                              String Title = URLEncoder.encode(tmpTitle);
                                                 }
<table>
  <tr>
    <td> <textarea rows="19" name="Body" cols="54"><%=Body%></textarea></td>
  </tr>
</table>
Thanks
0
 
LVL 7

Expert Comment

by:searlas
ID: 10834523
A textarea cannot display rendered HTML.  No doubt someone will point you at a few options out there that look like they do, but basically they hide the textarea and use iframes and massive amounts of javascript instead.  for instance:

http://www.interactivetools.com/products/htmlarea/
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 9

Expert Comment

by:Nick_72
ID: 10834529
oh...textarea...I missed that part :)

well, I'm not sure if that is possible. I know another thing that is possible though and could be equally as good, or better. That depends on if the user should be able to edit that text or not. With this example, he/she is not able to do that, but if it's only for presentation - that would suite just fine.

Check this example. It makes a 'fake' textarea which looks as an original, but which allows you to use ordinary html in it:

<HTML>
<head>
<STYLE>
.textAREA {border:3px ridge #dddddd;height:200;width:300;overflow-y:scroll;
border-right:3px double #bbbbbb; border-bottom:3px double #bbbbbb;}

.hiliteON {color:white;background-color:navy;font-family:arial;font-size:10pt}
.hiliteOFF {color:black;background-color:white;font-family:arial;font-size:10pt}
</STYLE>

</HEAD>
<BODY>
<div class="textAREA" style="position:absolute;left:165;top:115">
<li>test 1</li>
<li>test 2</li>
</div>
</BODY>
</HTML>

Hope it helps,

/Nick
0
 
LVL 7

Assisted Solution

by:searlas
searlas earned 500 total points
ID: 10834543
So... to get your 'body' displayed as you want, you shouldn't use a text area at all:
<table>
  <tr>
    <td> <textarea rows="19" name="Body" cols="54"><%=Body%></textarea></td>
  </tr>
</table>

becomes:
<%=Body%>
0
 
LVL 19

Expert Comment

by:Kuldeepchaturvedi
ID: 10834627
try


<td> <textarea rows="19" name="Body" DATAFORMATS="html" cols="54"><%=Body%></textarea></td>
0
 
LVL 19

Expert Comment

by:Kuldeepchaturvedi
ID: 10834643
ooops

it should be

<td> <textarea rows="19" name="Body" DATAFORMATAS="html" cols="54"><%=Body%></textarea></td>


http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/dataformatas_1.asp
0
 

Author Comment

by:jvoros1
ID: 10834656
The user has to be able to edit the text cause this is an update to what they added. SO i am not sure if it will work cause i have more then just that one row i have many rows in my table. And this page is an include in another page? Do you know maybe how i could use a hashcode to do this or a stringtokenizer is that possible some how?
0
 
LVL 19

Assisted Solution

by:Kuldeepchaturvedi
Kuldeepchaturvedi earned 500 total points
ID: 10834739
If all you want to do is to strip off the <LI> and </LI> tag than you can use string tokenizer to separate them..
Hashtable ht=new Hashtable();
int count =0;
StringTokenizer st  = new StringTokenizer(body,"<li>");
while(st.hasMoreElements())
{
String token = st.nextToken();
token = token.subString(0,token.indexOf("</li>");
//put this token where ever you want to..
hastable.put(count,token);
count++;
}

Here I am assuming that all the li tags are in small case....
0
 

Author Comment

by:jvoros1
ID: 10834750
I tried <td> <textarea rows="19" name="Body" DATAFORMATAS="html" cols="54"><%=Body%></textarea></td> too and it still comes up as
<li>       One</li>
 <li>       Two </li>
 <li>       three</li>
:(

0
 
LVL 9

Accepted Solution

by:
Nick_72 earned 1000 total points
ID: 10834757
I don't know how to display that 'dot' in a textarea, but if you can think of showing an asterisk or some other character instead, you could always use the replaceAll() method:

String newBody = Body.replaceAll("<li>", "* ");
newBody = newBody.replaceAll("</li>", "");

/Nick

0
 
LVL 9

Expert Comment

by:Nick_72
ID: 10834846
:)

actually, if you want a new line after every </li> you might want do like this instead:

newBody = newBody.replaceAll("</li>", "\n");

/Nick
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Moore’s Law has proven itself time and time again since it was first introduced. So what’s next? Will Moore’s law continue to remain relevant, or will new technology take over and bring us the next big advancement in computing?
Over time, the online landscape has altered considerably, but that’s nothing compared to the up-and-coming trends that will shape the web design industry in the coming year. Keep reading to find out which trends will shape B2B web design in 2018.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

839 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