473,406 Members | 2,894 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.

Insert javascript variable value in body of HTML page

Hello:

is it possible to insert the value of some JavaScript variable in the
body of HTML (for example the text on button, or at any part of the
HTML text part). Please tell me how to do this.

Thanks

Oct 18 '05 #1
4 3186
VK

ke**************@yahoo.com wrote:
is it possible to insert the value of some
JavaScript variable in the body of HTML
(for example the text on button
<script type="text/javascript">
function myFunction() {
document.forms[0].elements[0].value = 'Custom text';
// or:
// document.myForm.button001.value = 'Custom text';
// which does the same
}
</script>
<body onload="myFunction()">
....
<form name="myForm">
<input type="button" name="button001" value="Default text">
</form>
....
, or at any part of the HTML text part).


To *change* the content of a text block see
<http://www.jibbering.com/faq/#FAQ4_15> and related links.

To *insert/replace* some text of a text block, you need to use
TextRange
object
<http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/objects/obj_textrange.asp>
but it flyes as expected for IE only.
For other browser you need to use different legacy tricks. As these
tricks are numerous and their set/implementation depends heavily on
current tack, more clarification of your actual aim would be helpful.

Oct 18 '05 #2
See "InnerText" & "InnerHTML" properties for HTML objects and "value"
property for forms inputs.

Best, Ed.

Oct 18 '05 #3
Gomolyako Eduard wrote:
See "InnerText" & "InnerHTML" properties for HTML objects and "value"
property for forms inputs.

Best, Ed.

InnerText ? perhaps you mean: "innerText"?
The former doesn't exist, and the latter is unreliable(IE invention).
Mick
Oct 18 '05 #4
Mick White писал(а):
Gomolyako Eduard wrote:
See "InnerText" & "InnerHTML" properties for HTML objects and "value"
property for forms inputs.

Best, Ed.
InnerText ? perhaps you mean: "innerText"?


Yes, u right, i mean "innerText".
The former doesn't exist, and the latter is unreliable(IE invention).
Thx.
Mick


Oct 18 '05 #5

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

Similar topics

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
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
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...
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...
0
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...

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.