Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Is there a way to keep 2 textboxes the same???

Reply
Thread Tools

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

 
 
lewis_t@mittalsteel.com
Guest
Posts: n/a
 
      01-20-2006
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)?

 
Reply With Quote
 
 
 
 
Evertjan.
Guest
Posts: n/a
 
      01-20-2006
http://www.velocityreviews.com/forums/(E-Mail Removed) 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)
 
Reply With Quote
 
 
 
 
lewis_t@mittalsteel.com
Guest
Posts: n/a
 
      01-20-2006
Thank you very much for your reply.

Will the onkeyup event get triggered onload?

 
Reply With Quote
 
Evertjan.
Guest
Posts: n/a
 
      01-20-2006
(E-Mail Removed) 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)
 
Reply With Quote
 
David Dorward
Guest
Posts: n/a
 
      01-20-2006
(E-Mail Removed) 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
 
Reply With Quote
 
T L
Guest
Posts: n/a
 
      01-20-2006
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?

 
Reply With Quote
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      01-20-2006
(E-Mail Removed) 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
 
Reply With Quote
 
Thomas 'PointedEars' Lahn
Guest
Posts: n/a
 
      01-20-2006
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
 
Reply With Quote
 
T L
Guest
Posts: n/a
 
      01-20-2006
> 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.

 
Reply With Quote
 
rkc
Guest
Posts: n/a
 
      01-21-2006
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?



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a way to keep the StreamWriter open? Bishop ASP .Net 14 06-19-2009 08:34 PM
Is there any way to keep a systematic documentation of credi ANDANI The Lounge 2 06-04-2009 01:07 AM
Is there a way to keep scroll an ad Laura D. HTML 2 10-08-2007 07:38 AM
Is there any way to delete Total Access and still keep Accelerator Howard H. Computer Support 2 01-19-2006 06:28 PM
Is there a way to keep a specific EditCommandColumn from firing? needin4mation@gmail.com ASP .Net 1 08-12-2005 02:18 PM



Advertisments