By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,639 Members | 2,276 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,639 IT Pros & Developers. It's quick & easy.

Is there a way to keep 2 textboxes the same???

P: n/a
Is there a way have 2 textboxes on the same form where the value of the
first textbox is always the value of the 2nd textbox (even onload)?

Jan 20 '06 #1
Share this Question
Share on Google+
18 Replies


P: n/a
le*****@mittalsteel.com wrote on 20 jan 2006 in comp.lang.javascript:
Is there a way have 2 textboxes on the same form where the value of the
first textbox is always the value of the 2nd textbox (even onload)?


<input id=t1
onkeyup='document.getElementById("t2").value=this. value'>
<br>
<input id=t2
onkeyup='document.getElementById("t1").value=this. value'>
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jan 20 '06 #2

P: n/a
Thank you very much for your reply.

Will the onkeyup event get triggered onload?

Jan 20 '06 #3

P: n/a
le*****@mittalsteel.com wrote on 20 jan 2006 in comp.lang.javascript:
Thank you very much for your reply.

Will the onkeyup event get triggered onload?


No, but why should you?

At load time both <input's are empty,

or you van fill them with the same value, like:

<input value='blah'>
<input value='blah'>

or you can fill both by an onload script:

<body onload = 'document.getElementById("t1").value=
document.getElementById("t2").value="blah"'>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jan 20 '06 #4

P: n/a
T L
I didn't really explain what I am trying to accomplish... I have a form
with a large table displaying values I extract from a database. I want
to put some final totals from the table at the top of the form (ie:
number of rows with value x). I would rather not create arrarys or
loop thru the ADO recordset to calculate these values then go back
(movefirst) and loop thru again to display. I thought about putting a
hidden textbox at the bottom of the form that would update the textbox
at top of the form. Maybe there is a better way to do this?

Jan 20 '06 #5

P: n/a
le*****@mittalsteel.com wrote:
Thank you very much for your reply.
What reply?

http://www.safalra.com/special/googlegroupsreply/
http://oakroadsystems.com/genl/unice.htm#quote
Will the onkeyup event get triggered onload?


No.

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Jan 20 '06 #6

P: n/a
le*****@mittalsteel.com wrote:
Is there a way have 2 textboxes on the same form where the value of the
first textbox is always the value of the 2nd textbox (even onload)?


Quickhack:

<head>
...
<meta http-equiv="Content-Script-Type" content="text/javascript">
<script type="text/javascript">
function syncInputs(f, name1, name2)
{
var es;
if (f && (es = f.elements)
&& es[name1]
&& es[name2]
&& typeof es[name2].value != "undefined")
{
es[name2].value = es[name1].value;
}
}
</script>
</head>

<body onload="syncInputs(document.forms['form1'], 'text1', 'text2');">
...
<form ... name="form1">
<input name="text1" value="foo"
onchange="syncInputs(this.form, this.name, 'text2');">
<input name="text2">
</form>
...
</body>
PointedEars
Jan 20 '06 #7

P: n/a
T L wrote:
^^^
Hmmm... :)
[...] I have a form with a large table displaying values I extract from a
database. I want to put some final totals from the table at the top of
the form (ie: number of rows with value x). I would rather not create
arrarys or loop thru the ADO recordset to calculate these values then go
back (movefirst) and loop thru again to display. I thought about putting
a hidden textbox at the bottom of the form that would update the textbox
at top of the form. Maybe there is a better way to do this?


I have not used ADO much recently, but I think you want to do a query and
then use the Count property --

<URL:http://msdn.microsoft.com/library/en-us/ado270/htm/mdmscadoproperties.asp>

-- or simply use a variable that you increase as you iterate through the
recordset.
PointedEars
Jan 20 '06 #8

P: n/a
T L
> PointedEars wrote:
I have not used ADO much recently, but I think you want to do a query and
then use the Count property --

<URL:http://msdn.microsoft.com/library/en-us/ado270/htm/mdmscadoproperties.asp>

-- or simply use a variable that you increase as you iterate through the
recordset.


Yes - it is not the total number of rows (so I can't use ADOrs.Count),
but I have a variable that counts the values of interest. It counts
these values as it gets them from ADO and builds the HTML to display
(ASP).
The problem I am having is when I am done building this HTML table I
want to update a textbox at the top of the form with some totals.

Jan 20 '06 #9

P: n/a
On 2006-01-20, T L <le*****@mittalsteel.com> wrote:
Yes - it is not the total number of rows (so I can't use ADOrs.Count),
but I have a variable that counts the values of interest. It counts
these values as it gets them from ADO and builds the HTML to display
(ASP).
The problem I am having is when I am done building this HTML table I
want to update a textbox at the top of the form with some totals.


you could put code in your onload to update the top field.
--

Bye.
Jasen
Jan 21 '06 #10

P: n/a
rkc
T L wrote:
PointedEars wrote:
I have not used ADO much recently, but I think you want to do a query and
then use the Count property --

<URL:http://msdn.microsoft.com/library/en-us/ado270/htm/mdmscadoproperties.asp>

-- or simply use a variable that you increase as you iterate through the
recordset.

Yes - it is not the total number of rows (so I can't use ADOrs.Count),
but I have a variable that counts the values of interest. It counts
these values as it gets them from ADO and builds the HTML to display
(ASP).
The problem I am having is when I am done building this HTML table I
want to update a textbox at the top of the form with some totals.


If the calculations aren't the result of any user action after the
fact, why don't you just do them using sql on the server?

Jan 21 '06 #11

P: n/a
T L wrote:
PointedEars wrote:
I have not used ADO much recently, but I think you want to do a query and
then use the Count property --

<URL:http://msdn.microsoft.com/library/en-us/ado270/htm/mdmscadoproperties.asp>
-- or simply use a variable that you increase as you iterate through the
recordset.


Yes - it is not the total number of rows (so I can't use ADOrs.Count),
but I have a variable that counts the values of interest. It counts
these values as it gets them from ADO and builds the HTML to display
(ASP).
The problem I am having is when I am done building this HTML table I
want to update a textbox at the top of the form with some totals.


You do not have to generate the HTML code while you iterate the
recordset, you can concatenate a string that you write later.

Please provide attribution of quoted material.
PointedEars
Jan 23 '06 #12

P: n/a
Jasen Betts wrote:
On 2006-01-20, T L <le*****@mittalsteel.com> wrote:
Yes - it is not the total number of rows (so I can't use ADOrs.Count),
but I have a variable that counts the values of interest. It counts
these values as it gets them from ADO and builds the HTML to display
(ASP).
The problem I am having is when I am done building this HTML table I
want to update a textbox at the top of the form with some totals.


you could put code in your onload to update the top field.


Following this suggestion would introduce a dependendy on client-side
scripting and DOM features unnecessarily.
PointedEars
Jan 23 '06 #13

P: n/a
On 2006-01-20, T L <le*****@mittalsteel.com> wrote:
I didn't really explain what I am trying to accomplish... I have a form
with a large table displaying values I extract from a database. I want
to put some final totals from the table at the top of the form (ie:
number of rows with value x). I would rather not create arrarys or
loop thru the ADO recordset to calculate these values then go back
(movefirst) and loop thru again to display. I thought about putting a
hidden textbox at the bottom of the form that would update the textbox
at top of the form. Maybe there is a better way to do this?


if you're using PHP look into using output buffering (ob_start() IIRC)
before writing the first field ans "saving up" the page content until
you have calculated the total, and can finish the output buffing and write
the total field and then the buffer.

Bye.
Jasen
Jan 24 '06 #14

P: n/a
T L

Jasen Betts wrote:

you could put code in your onload to update the top field.


I tried to link 2 textboxes together in the onload event, like what
Pointed Ears suggested without the ="blah" (because I don't know the
value at that point) but no luck. I assume it is setting textbox 1 to
texbox 2 but at load time both values are blank.

Jan 24 '06 #15

P: n/a
T L

rkc wrote:

If the calculations aren't the result of any user action after the
fact, why don't you just do them using sql on the server?


This is the way it works now. It is using ODBC to a VAX Oracle RDB
database. To do the calculations is very expensive and I was trying to
avoid DB hits.

Jan 24 '06 #16

P: n/a
T L

Thomas 'PointedEars' Lahn wrote:

You do not have to generate the HTML code while you iterate the
recordset, you can concatenate a string that you write later.


No I don't have to necessarily write the html out while I am iterating
thru the recordset. It will take a little doing but I can defineately
do that. Thanks...

Jan 24 '06 #17

P: n/a
VK

T L wrote:
I didn't really explain what I am trying to accomplish... I have a form
with a large table displaying values I extract from a database. I want
to put some final totals from the table at the top of the form (ie:
number of rows with value x). I would rather not create arrarys or
loop thru the ADO recordset to calculate these values then go back
(movefirst) and loop thru again to display. I thought about putting a
hidden textbox at the bottom of the form that would update the textbox
at top of the form. Maybe there is a better way to do this?


Why don't you want to use thead and tfoot sections? They are specially
convenient for large databound tables (unless I'm missing some
details).

<table>
<thead>
....
</thead>
<tfoot>
....
</tfoot>
<tbody>
....
</tbody>
</table>

P.S. Yes, thead-tfoot-tbody, this is the right standard endorsed
sequence. You may guess now why ;-)

Jan 24 '06 #18

P: n/a
VK wrote on 24 jan 2006 in comp.lang.javascript:
P.S. Yes, thead-tfoot-tbody, this is the right standard endorsed
sequence. You may guess now why ;-)


Thank you for this allowance.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jan 24 '06 #19

This discussion thread is closed

Replies have been disabled for this discussion.