473,394 Members | 1,671 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,394 software developers and data experts.

How display dynamic text string?

I would like to have a errorMessage displayed in a webpage. When a
function is called the text changes. My code below replaces the html
page with the errorMessage instead of embedding it into the html code.
Its a stripped down version of the actual code but contains the same 3
pieces: An action to validate a form, the function to check if the
form is valid, and a function to display the type of error. Any
suggestions? -Nick
<html>
<head>
<script language="JavaScript" type="text/JavaScript">

function isError(error) {
if (error == 'yes') displayError("There has been an error");
}

</script>
</head>
<body>
<script language="JavaScript" type="text/JavaScript">

function displayError(errorMessage) {
document.write(errorMessage);
}

</script>
<a href="#" onClick="isError('yes')">Display Error</a>
</body>
</html>
Jul 23 '05 #1
4 5078
Nick wrote:
I would like to have a errorMessage displayed in a webpage. When a
function is called the text changes. My code below replaces the html
page with the errorMessage instead of embedding it into the html code.
Its a stripped down version of the actual code but contains the same 3
pieces: An action to validate a form, the function to check if the
form is valid, and a function to display the type of error. Any
suggestions? -Nick
<html>
<head>
<script language="JavaScript" type="text/JavaScript">

function isError(error) {
if (error == 'yes') displayError("There has been an error");
}

</script>
</head>
<body>
<script language="JavaScript" type="text/JavaScript">

function displayError(errorMessage) {
document.write(errorMessage);
}

</script>
<a href="#" onClick="isError('yes')">Display Error</a>
</body>
</html>


Yeah... do something like this:

<SPAN id=errorMessageText></SPAN>

Then, in a script, you can do this:

<SCRIPT type="text/javascript">
function displayError(errorMessage) {
document.getElementById("errorMessageText").innerT ext = errorMessage;
}
</SCRIPT>

If you want more formatting than plain text, use innerHTML instead of
innerText

B

Jul 23 '05 #2
Exactly what I needed. Thanks so much Brian for taking the time to
post. You rock. -Nick
Jul 23 '05 #3
On Tue, 27 Apr 2004 07:16:22 -0400, Brian Genisio <Br**********@yahoo.com>
wrote:

[snip]
<SPAN id=errorMessageText></SPAN>

Then, in a script, you can do this:

<SCRIPT type="text/javascript">
function displayError(errorMessage) {
document.getElementById("errorMessageText").innerT ext = errorMessage;
}
</SCRIPT>

If you want more formatting than plain text, use innerHTML instead of
innerText


However, it is important to note that innerText isn't supported by the
Mozilla family of browsers (amongst others, no doubt). innerHTML is better
supported.

Mike

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 23 '05 #4
Michael Winter wrote:
On Tue, 27 Apr 2004 07:16:22 -0400, Brian Genisio
<Br**********@yahoo.com> wrote:

[snip]
<SPAN id=errorMessageText></SPAN>

Then, in a script, you can do this:

<SCRIPT type="text/javascript">
function displayError(errorMessage) {
document.getElementById("errorMessageText").innerT ext = errorMessage;
}
</SCRIPT>

If you want more formatting than plain text, use innerHTML instead of
innerText

However, it is important to note that innerText isn't supported by the
Mozilla family of browsers (amongst others, no doubt). innerHTML is
better supported.

Mike


Woops :) Yeah, I knew that. My bad.
Brian

Jul 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: K | last post by:
I have found a script online that I want to use (I am new to PHP). It creates dynamic images based on the text that you pass it. However, no matter how I try, I can't get anything other than a...
2
by: Tyrone Slothrop | last post by:
I am coding a site which involves uploading images. All of the PHP and display is OK but the client wants to be able to display the image thumbnail on the upload page and show the full image on...
7
by: Mike Livenspargar | last post by:
We have an application converted from v1.1 Framework to v2.0. The executable references a class library which in turn has a web reference. The web reference 'URL Behavior' is set to dynamic. We...
0
by: Barb | last post by:
Has anyone seen this happen? I have pages with <asp:Textbox> and <asp:DropDownList> controls on them. Some of them display differently. Some are recessed with the left & top borders being gray...
0
by: André Nobre | last post by:
Hi all, I´m having a little trouble with a requiredfieldvalitor in a custom control. I put a validator in runtime, as this code: protected override void OnInit(EventArgs e) { if...
3
by: c676228 | last post by:
Hi everyone, I have a piece of code in sales.aspx.vb like this: Protected WithEvents Message As System.Web.UI.WebControls.Label Try ... ChartImage.ImageUrl = "ChartGenerator.aspx?" + DataStr +...
2
by: assgar | last post by:
Hi Developemnt on win2003 server. Final server will be linux Apache,Mysql and PHP is being used. I use 2 scripts(form and process). The form displays multiple dynamic rows with chechboxs,...
0
by: MaryamSh | last post by:
Create Dynamic Dropdownlist Controls and related event -------------------------------------------------------------------------------- Hi, I am creating a Dynamic Search in my application. I...
2
by: englishman69 | last post by:
Hello, I have been banging my head against this one for a while... Searches online have revealed many different proposals for correcting my issue but none that I can follow! My basic situation...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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,...
0
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...
0
tracyyun
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 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.