473,406 Members | 2,745 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

unordered list editor javascript

oll3i
679 512MB
why when i try to make the string(unordered 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 2376
acoder
16,027 Expert Mod 8TB
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 512MB
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 Expert Mod 8TB
What does the updated code look like?
Feb 15 '08 #4
oll3i
679 512MB
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 Expert Mod 8TB
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
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
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...
1
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...
3
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
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...
5
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...
2
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...
2
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:...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.