473,799 Members | 3,025 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3199
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.valu e = 'Custom text';
// which does the same
}
</script>
<body onload="myFunct ion()">
....
<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.c om/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.a sp>
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
9688
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
10268
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...
0
10031
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9079
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 projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7571
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
5593
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4146
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
3762
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2941
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.