Why
var offer=document.getElementById("editor_displaying_t ext").value;
returns undefined?
Thank You
13 2147
Why
var offer=document.getElementById("editor_displaying_t ext").value;
returns undefined?
Thank You
it's really hard to tell without knowledge of what "editor_displaying_text" is.
I'm going to go on a limb and say not all elements have a property called "value"... in fact, most do not. Unless "editor_displaying_text" is an "OBJECT", "PARAM", "LI", "INPUT" or "BUTTON", value will return undefined.
Read the DTD: http://www.w3.org/TR/html/DTD/xhtml1-transitional.dtd, do a CTRL-F for "value" and see how often it shows up.... not very often.
You may want to check out the "childNodes" array for a list of dom elements within the element -- or, if you like the cheap & easy way out, innerHTML.
It's an editable div which id is editor_displaying_text
Thank You
You'll have to show your code. Where do you define it within the page?
- function makeBold(txt){
-
-
var offer=document.getElementById("editor_displaying_text").value;
-
-
-
offer=offer+'\n' ;
-
-
offer=offer.replace(txt,'<b>'+ txt +'</b>');
-
-
document.getElementById("editor_displaying_text").value = offer;
-
}
-
- function makeBold(txt){
-
-
var offer=document.getElementById("editor_displaying_text").value;
-
-
-
offer=offer+'\n' ;
-
-
offer=offer.replace(txt,'<b>'+ txt +'</b>');
-
-
document.getElementById("editor_displaying_text").value = offer;
-
}
-
That code still does not show the <div>
Ronald
...and the code for the "editor"?
Edit: Ah, ronverdonk replied in the meantime!
...and the code for the "editor"?
Edit: Ah, ronverdonk replied in the meantime!
Won't do it again.
Ronald
Won't do it again.
Ronald
No, I didn't mean you did something wrong (in fact, quite the opposite)! I was in the middle of replying and by the time I replied, you'd already done so. I just added an edit in case it looked like a duplicate response.
No, I didn't mean you did something wrong (in fact, quite the opposite)! I was in the middle of replying and by the time I replied, you'd already done so. I just added an edit in case it looked like a duplicate response.
I was just kidding. Nobody prevents me from meddling in other forums/fora/forae?
Ronald
-
<script language = "JavaScript">
-
-
function getSelectedText(){
-
var txt = '';
-
if (document.getSelection) txt = document.getSelection();
-
else if (document.selection) txt = document.selection.createRange().text;
-
-
return txt;
-
-
}
-
-
-
function makeBold(txt){
-
-
var offer=document.getElementById("editor_displaying_text").value;
-
-
document.write(offer);
-
offer=offer+'\n' ;
-
-
offer=offer.replace(txt,'<b>'+ txt +'</b>');
-
-
document.getElementById("editor_displaying_text").value = offer;
-
}
-
-
-
</script>
-
</HEAD>
-
<BODY>
-
<form name="editor">
-
<input type="button" name="bold" class="editor_bold" onClick="makeBold(getSelectedText())">
-
<input type="button" name="unordered_list" class="editor_unordered_list">
-
<input type="button" name="anchor" class="editor_anchor">
-
-
</form>
-
-
<div id="editor_displaying_text" contenteditable="true" indicateeditable="true"></div>
-
it is just my attempt to write a simple editor
Thank You
I was just kidding. Nobody prevents me from meddling in other forums/fora/forae?
Ronald
Lol, you never know these days how people are easily offended.
Oll3i, as tswaters mentioned earlier, the div tag doesn't have a value attribute. Either use innerHTML or the DOM methods.
One other thing, you can't use document.write after the document has loaded.
thank You that works I'm happy :)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: John Ramsden |
last post by:
.... when the id 'junk' doesn't exist anywhere in the document,
instead of returning 'object'?!
I am using Javascript for a drop-down menu, slightly adapted from
one by Angus Turnbull (see...
|
by: s_m_b |
last post by:
here's the code (running from an ASP page):
<script language = "JavaScript" type="text/javascript">
function initStuff() {
var scanWindow = window.open('scanning.htm', 'scanning',...
|
by: Sam Samnah |
last post by:
I posted this during the weekend and I think it was missed so I am posting
it again. I'm in real big trouble with this and need help desperately. Any
suggestions will be met with unbelievable...
|
by: dd |
last post by:
Hello all. First, I'm a newbie to javascript but not to ASP. Secondly
I've been searching for the answer for two hours and I decided to
finally post this question. I'm trying to take a...
|
by: preet |
last post by:
On first execution of StartSurf() the siteloc returns undefined
On second excution and after that there is no problem.
StartSurf is called from a button press, which becomes invisible for 30...
|
by: Moses |
last post by:
Hi All,
Is is possible to catch the error of an undefined element while
creating an object for it.
Consider we are not having an element with id indicator but we
are trying to make the object...
|
by: number1yan |
last post by:
Can anyone help me,
i am creating a website and am using a php script that recomends the website to other people. I keep getting the same error and can not work out why. The error is:
Notice:...
|
by: Alexio |
last post by:
I need to apply an onLoad() event to call the function displayed below.
I tried <body bgcolor="#B3FFB3" onLoad="display(obj)"> and it comes up with an error message of obj undefined.
My question is...
|
by: selvialagar |
last post by:
<?php
require_once('database_conn.php');
session_start();
if(isset($_SESSION))
{
if(isset($_GET) && $_GET=="submit")
{
$cust_id=$_POST;
echo $cust_id;
}
|
by: hemantbasva |
last post by:
We have designed an aspx page having five ajax tab in it. the data of first four are designed on page whereas for the fifth tab it renders a user control named MYDOMAIN. in the tab container's even...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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,...
|
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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
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...
| |