Click to See Complete Forum and Search --> : desplaying...


Justin
05-20-2003, 02:59 PM
how do you desplay varibules in text that change withouut useing formboxes/values

khalidali63
05-20-2003, 03:06 PM
suppose you want to display a variable in h3 element

<script type="text/javascript">
<!--
function Process(){
var variable = "This is dynamic text"
document.getElementById("header3").innerHTML = variable;
}
//-->
</script>
</head>
<body >
<h3 id="header3"></h3><br/><br/>
<form id="form1" action="" onsubmit="">
<input type="button" value="process" onclick="Process()"/>
</form>

Justin
05-20-2003, 03:10 PM
thanks it helped alot

Jona
05-20-2003, 03:15 PM
For Netscape 4.0, you would use this:


<script type="text/javascript">
<!--
function Process(){
var variable = "This is dynamic text"
if(document.getElementById){
document.getElementById("header3").innerHTML = variable; }
if(navigator.appName=="Netscape" && parseInt(navigator.appVersion)==4){
document.layers["header3"].document.open();
document.layers["header3"].document.write(variable);
document.layers["header3"].document.close();
}
//-->
</script>
</head>
<body>
<h3 id="header3"></h3><br/><br/>
<form id="form1" action="" onsubmit="">
<div>
<input type="button" value="process" onclick="Process()">
</div>
</form>


Just so you know. ;)

Justin
05-20-2003, 03:18 PM
again

Justin
05-20-2003, 03:22 PM
Posts: 2395
suppose you want to display a variable in h3 element

<script type="text/javascript">
<!--
function Process(){
var variable = "This is dynamic text"
document.getElementById("header3").innerHTML = variable;
setTimeout("Process();",1000)
}
//-->
</script>
</head>
<body >
<h3 id="header3"></h3><br/><br/>

Then add the process() in the onload section

Jona
05-20-2003, 03:25 PM
That would work fine, but nothing in the text would change. You would have to dynamically change the variable's string value, otherwise it will just do nothing except for change the text the first time.

Justin
05-20-2003, 03:27 PM
i know

THANKS ALOT

Jona
05-20-2003, 03:32 PM
You're quite welcome, but don't forget to thank Khalid as well! He helped. ;)