473,804 Members | 3,063 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

unordered list editor javascript

oll3i
679 Contributor
why when i try to make the string(unordere d list) to be in a div it apears beside the div
Expand|Select|Wrap|Line Numbers
  1.  function makeUnorderedList(txt){
  2.  var tempText="";    
  3.  var splitResult = txt.split('\n');
  4.  var offer=document.getElementById("editor_displaying_text").innerHTML;
  5.  offer=offer.replace(txt,"");
  6.  
  7.  
  8.  for(i = 0; i < splitResult.length; i++){
  9.     tempText=splitResult[i];
  10.     tempText=tempText.replace(splitResult[i],'<li>'+splitResult[i]+'</li>');
  11.     offer+=tempText;    
  12. }
  13. offer=offer.replace(tempText,'<ul>'+tempText+'</ul>');
  14. document.getElementById("editor_displaying_text").innerHTML = offer;
  15. }
Feb 14 '08 #1
5 2418
acoder
16,027 Recognized Expert Moderator MVP
tempText is the last split item on line 13. You need to replace the whole text (txt) in offer. Remove line 5 and make the replacement on line 13.
Feb 15 '08 #2
oll3i
679 Contributor
hmm i did that but still get the unordered ,list underneath the div and the content of the div doesn't change
Thank You
Feb 15 '08 #3
acoder
16,027 Recognized Expert Moderator MVP
What does the updated code look like?
Feb 15 '08 #4
oll3i
679 Contributor
Expand|Select|Wrap|Line Numbers
  1.  function makeUnorderedList(txt){
  2.  var tempText="";
  3.  var textToRemove="";    
  4.  var splitResult = txt.split('\n');
  5.  var offer=document.getElementById("editor_displaying_text").innerHTML;
  6.  
  7.  
  8.  
  9.  for(i = 0; i < splitResult.length; i++){
  10.     tempText=splitResult[i];
  11.     tempText=tempText.replace(splitResult[i],'<li>'+splitResult[i]+'</li>');
  12.     textToRemove+=tempText;
  13.     offer+=tempText;    
  14. }
  15. offer=offer.replace(textToRemove,'<ul>'+textToRemove+'</ul>');
  16. document.getElementById("editor_displaying_text").innerHTML = offer;
  17. }
  18.  
it only makes unordered list on selected text but it doesn't display it in a div
thank You
Feb 15 '08 #5
acoder
16,027 Recognized Expert Moderator MVP
Try alerting txtToRemove, offer and tempText to see if they match for the replace to work.
Feb 16 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
10046
by: michael | last post by:
Good Morning, I have an unordered list similar to: <ul> <li>Item 1</li> <li>Item 2</li> <li>Item 3</li> </ul>
5
2314
by: ibiza | last post by:
Hi all, I have a question which I have no ideal of the answer...I am currently working on a web application and at some time, I have a string representing a short text. This could be a simple example : "This is my list :\n\r-list item 1\n\r-list item 2\n\r-list item 3\n\r\n\rThis was a great list." Let's say this outputs like that :
1
3289
by: Eric Jones | last post by:
Hello newsgroup members, I really like CSS, and have created some button like navigation UL/li, etc. I have hover, change color, etc. I am using the "link" as a button, and using ajax and javascript and php to do things. the user clicks one of the links, and I want things to happen, I use the onclick event (of the li <li id="button1" onclick=getData(ajax HttpReq)) but I have 3 other things i would like to happen with the same...
3
3499
by: User | last post by:
Hi, Is it possible to transform Ordered/Unordered list into navigation dropdown menus? Is this effect achieved by CSS? or via Javascript? PLease advise Thanks.
0
1344
by: roscoedesign | last post by:
html: http://roscoecreations.com/exitpro/ css: http://roscoecreations.com/exitpro/css/style.css js: http://roscoecreations.com/exitpro/javascript/main.js Recently, I have had some big problems with white space being created by IE6. Now that I have conquered that problem it has popped up again only with IE7. I have been testing this for an entire day and still no luck. I don't understand because when the page loads everything looks fine, but...
5
11587
by: ranyeng | last post by:
Suppose I have an Unordered List in my HTML file: <html> <head> <SCRIPT LANGUAGE="JavaScript"> function remove(){ //code to remove the old elements var d=document.getElementById("forum"); d.parentNode.removeChild(d);
2
2180
by: torweb | last post by:
I'm using an image for an unordered list, which works fine. The problem is, the image is also appearing in my numbered "ordered list." Here is my code for the unordered list:...and thanks in advance: ul { font-family: Arial; font-size: 12px; color: #424E51; font-style: normal line-height: 17px; font-weight: normal; font-variant: normal;
2
2226
by: asc4john | last post by:
When including an unordered list in an unordered list: Should it be included as a "list" item as in: <ul><liitem</ li><ul.... </ul<liitem</li</ul> or included in the LI element as in: <ul><liitem</li<li<ul... </ul></li></ul>? or does it matter?
0
9591
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10594
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10343
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10331
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7631
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6861
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5667
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4306
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3831
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.