473,396 Members | 1,671 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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

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
18 1477
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
Thank you very much for your reply.

Will the onkeyup event get triggered onload?

Jan 20 '06 #3
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Drew | last post by:
I have a db table like the following, UID, int auto-increment RegNo Person Relation YearsKnown Now here is some sample data from this table,
4
by: Kevin H | last post by:
Apologies in advance if this sounds slow-witted, but I didn't find it here. Need to populate some textboxes on a form. While I could hard code it (the number of options aren't that high), it...
8
by: Andy Weinmann | last post by:
I am trying to make a form in which i can view the ihe information for companies. I have a combobox which contains all of the work categories that the companies fit into. I have gotten the...
4
by: Jason M | last post by:
Hi, Im very new to c#, so forgive me if this is a really stupid question. Im trying to create a form for entering purchase requests. For each line item I have a quantity, a description unit cost...
1
by: elain | last post by:
Hi all, My webform contains a repeater, and every item in the repeater is a user control which contains several textboxes. Each time when the page is loaded, I bind a dataset to this repeater to...
3
by: Bruce W.1 | last post by:
I need to do a post on the client side (with an html button) to another aspx URL, while keeping the viewstates. So I made an html button with onClick="location.href='whatever.aspx?state=true'" ...
2
by: Lenster | last post by:
I'm having problems using the errorprovider in VB.NET to automatically display an error icon next to textboxes bound to the same dataset as the errorprovider. The sequence of events is : ...
1
by: Steve Amey | last post by:
Hi all I have a function that gets information from a database and merges the DataTable into a DataSet that some controls are bound to. What I would like is for the information to be merged in...
8
by: clintonG | last post by:
I have to get to this later tonight or tommorrow...and wonder... There's two TextBoxes in a Wizard Step posing an either-or situtation. Only one or the other TextBox may pass data. The...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...

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.