468,532 Members | 1,653 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,532 developers. It's quick & easy.

Text input value equal to a variable

Is there a way to have a text input field equal some variable value so that it
changes if that variable changes? It does not have to by dynamic.

<INPUT TYPE="TEXT" NAME="hW" size="4" value=some variable>

Thanks,
Jeff
Jul 20 '05 #1
5 9730
gf
"JeffFinnan" <je********@aol.com> wrote in message
news:20***************************@mb-m15.aol.com...
Is there a way to have a text input field equal some variable value so that it changes if that variable changes? It does not have to by dynamic.

<INPUT TYPE="TEXT" NAME="hW" size="4" value=some variable>

Thanks,
Jeff

This will place the value of Field1 into Field2 as soon as Field1 loses its
focus

<form name='myform1'>
Field1: <input name='f1' onChange='document.myform1.f2.value=this.value'>
<br /><br />
Field2: <input name='f2'>
</form>

or

<form name='myform2'>
Field1: <input name='f1'>
<br /><br />
Field2: <input name='f2' onFocus='this.value=document.myform2.f1.value'>
</form>

Jul 20 '05 #2
Lee
JeffFinnan said:

Is there a way to have a text input field equal some variable value so that it
changes if that variable changes? It does not have to by dynamic.


You want it to change if the variable changes, but it doesn't have
to be dynamic? You're not being clear. What is it that you're
trying to do?

Jul 20 '05 #3
>You want it to change if the variable changes, but it doesn't have
to be dynamic? You're not being clear. What is it that you're
trying to do?


==============
I have a frame load with a default value for a parameter that is use for sizing
a plugin (Chime). I then want to have a input box show this default value but
then allow a new number to be put in so that when the frame is reloaded, the
plugin has this new value and the new value is shown in the input box. I looked
at what gf******@earthlink.net had written. I got it to do the above with

=============================
<form name=form2>
<input type=button onClick="resetFile()" value="Reset/Reload">
&nbsp;&nbsp;&nbsp; Height and Width of Chime window=
<INPUT NAME="hW" size="6" onFocus='this.value=parent.upper.heightWidth' >

</form>
<SCRIPT LANGUAGE=JAVASCRIPT>
document.form2.hW.focus();
</SCRIPT>
=============================

The statement, document.form2.hW.focus();, makes the number (default or new)
appear in the box when the page loads or reloads.

If there is a better way, let me know.

Thanks,
Jeff
Jul 20 '05 #4
=============================
<form name=form2>
<input type=button onClick="resetFile()" value="Reset/Reload">
Height and Width of Chime window=
<INPUT NAME="hW" size="6" onFocus='this.value=parent.upper.heightWidth' >

</form>
<SCRIPT LANGUAGE=JAVASCRIPT>
document.form2.hW.focus();
</SCRIPT>
=============================
This works fine in IExplorer. I was just checking Netscape 4.8 and I notice the
new value of hW goes back to the default, not the new number.

setFile() is in an external js file. The function is

function resetFile() {
parent.upper.heightWidth = parent.viewer.document.form2.hW.value;
parent.viewer.document.location.href = "chimeviewer.html"

}
Jul 20 '05 #5
>=============================
<form name=form2>
<input type=button onClick="resetFile()" value="Reset/Reload">
Height and Width of Chime window=
<INPUT NAME="hW" size="6" onFocus='this.value=parent.upper.heightWidth' >
</form>
<SCRIPT LANGUAGE=JAVASCRIPT>
document.form2.hW.focus();
</SCRIPT>
=============================
This works fine in IExplorer. I was just checking Netscape 4.8 and I notice
the
new value of hW goes back to the default, not the new number.


Actually, I was just rechecking and I notice that anytime I click on the page
the value of hW always goes back to the default in Netscape 4.8.
Jul 20 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by FUGATO | last post: by
7 posts views Thread by Chuck Anderson | last post: by
13 posts views Thread by sugard | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.