473,378 Members | 1,391 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,378 software developers and data experts.

Copy info from 1 text box to another.....

Hi,

I hope this is the correct place for this post.

I have an asp page with a form.
The form has 2 text boxes for entering a serial number range.
first serial & last serial

In a variable on the asp page I have a quantity.
What I want is that when the user enters a serial number in the first
text box and presses the tab key to set focus to the second text box,
I want the second box to copy the first, but to increase by the qty in
my variable

i.e. Text Box 1:
User types: 1104555666 and presses tab

Qty in variable is 10

1104555666 should increase by 10 but include the first, i.e. -1 on the
end.

Text box 2 should then display 1104555675
How is this possible ?

Appreciate your help
David
Jul 23 '05 #1
4 2940
In article <c1**************************@posting.google.com >, david@scene-
double.co.uk enlightened us with...
In a variable on the asp page I have a quantity.
What I want is that when the user enters a serial number in the first
text box and presses the tab key to set focus to the second text box,
I want the second box to copy the first, but to increase by the qty in
my variable

Okay, ASP runs on the server. Javascript runs on the client. So, the
important question is whether you expect that ASP variable to change based on
what the client entered. If so, use postback and do this with ASP.
If not, it's just mostly normal javascript with one little piece generated by
ASP.
i.e. Text Box 1:
User types: 1104555666 and presses tab

Qty in variable is 10


Okay, the variable is only 10 when the doc is still on the server. I'll call
the variable myVariable for both server-side and client-side and assume it is
NOT a string (i.e. is integer, float, etc)...
<script type="text/javascript">
var myVariable = <%= myVariable %>;
</script>

Now you can access the variable through myVariable on the client. You can
change the value of the javascript variable as needed.

But, as I said, if you expect the ASP var to change, sorry, it can't be done
on the client. The server has already finished with it.
Using postback sends form data back to the server for another round of
processing without wiping out the form values. I believe it is only available
in .NET, not ASP classic.

--
--
~kaeli~
"When dogma enters the brain, all intellectual activity ceases"
-- Robert Anton Wilson
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #2
David wrote:
[...]

How is this possible ?


Client JS should be something like:

<script type="text/javascript">
// I've made theRange as a global, but could be
// local inside the function
var theRange = 10;

function doCalc(x,y){
y.value = 1*x.value + 1*theRange - 1;
}
</script>
<form action="">
<input type="text" width="100px" name="in1" id="in1"
onblur="doCalc(this,this.form.qty)">
<input type="text" width="20px" name="qty" id="qty">
</form>

Just set the value of "theRange" from the server, or allow the user to
modify it in the page.

Rob.
Jul 23 '05 #3
kaeli <ti******@NOSPAM.comcast.net> wrote in message news:<MP************************@nntp.lucent.com>. ..
In article <c1**************************@posting.google.com >, david@scene-
double.co.uk enlightened us with...
In a variable on the asp page I have a quantity.
What I want is that when the user enters a serial number in the first
text box and presses the tab key to set focus to the second text box,
I want the second box to copy the first, but to increase by the qty in
my variable


Okay, ASP runs on the server. Javascript runs on the client. So, the
important question is whether you expect that ASP variable to change based on
what the client entered. If so, use postback and do this with ASP.
If not, it's just mostly normal javascript with one little piece generated by
ASP.
i.e. Text Box 1:
User types: 1104555666 and presses tab

Qty in variable is 10


Okay, the variable is only 10 when the doc is still on the server. I'll call
the variable myVariable for both server-side and client-side and assume it is
NOT a string (i.e. is integer, float, etc)...
<script type="text/javascript">
var myVariable = <%= myVariable %>;
</script>

Now you can access the variable through myVariable on the client. You can
change the value of the javascript variable as needed.

But, as I said, if you expect the ASP var to change, sorry, it can't be done
on the client. The server has already finished with it.
Using postback sends form data back to the server for another round of
processing without wiping out the form values. I believe it is only available
in .NET, not ASP classic.

--


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<title>untitled</title>
<script type="text/javascript">

/*
* asp: var qty = <%= qty %>;
*/

var qty = 10; //output

function fieldchk(obj)
{
var v = obj.value;
if (/\D/g.test(v))
{
alert('The first serial number must consist of digits only.');
obj.value = '';
setTimeout(function(){obj.focus();}, 50);
return;
}
else obj.form.elements.lastserial.value = v - 1 + qty;
}

</script>
</head>
<body>
<form style="width:220px;">
first serial number » <input type="text" name="firstserial" value=""
size="10" onchange="fieldchk(this)" />
last serial number » <input type="text" name="lastserial" value=""
size="10" readonly="readonly" style="border:none;" />
</form>
</body>
</html>
Jul 23 '05 #4
Thanks Rob,

Works brilliantly !!

I have only one issue.
Sometimes my users need to enter a 0 (Zero) in text box 1 if there are
no serial numbers for this particular item.

If the user enters a 0, how can I adapt the code to copy only a 0 to
textbox 2 if a 0 is entered in text box 1.

Otherwise the function should work as you wrote.

Appreciate your thoughts.
David

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Khue Pham | last post by:
Does anyone knows how to copy database from one server to another. By copying I mean literally everything, not just the database. I know we can dump the database from one server then reload it to...
2
by: Anna | last post by:
Hi all. I am trying to write a stylesheet that will structure the input HTML file in the following way: For each heading of level n it needs to enclose the heading and all its content until the...
0
by: Tess | last post by:
Hi, Long time reader, first time poster... Any help is appreciated. I have a few questions regarding Winform controls embedded within an html page. For more info please see the appendix. Now,...
3
by: Rachel Suddeth | last post by:
This may not be the right forum, but it's a problem I chiefly come across when trying to post here. When I do a copy/paste from VS, the text always looks really weird (and even if I'm in an...
7
by: lgbjr | last post by:
Hello All, I¡¯m using a context menu associated with some pictureboxes to provide copy/paste functionality. Copying the image to the clipboard was easy. But pasting an image from the clipboard...
0
by: igendreau | last post by:
I have a database with a Header table. Each record in tblHeader has two One-to-Many Relationships: with tblLines and tblKeys. The HeaderID field ties tblHeader to the other two tables. The data...
3
by: Richnep | last post by:
Hi all, I have tabbed subforms where I need to copy one field value from one subform over to another subform. Although I can run an update query to accomplish this I would like to do it through...
3
by: usman | last post by:
Hi I have a windows service that backups a folder onto another location on the same computer. The service is written in C#. The size of the original folder is large i.e. over 8 GB. Also the...
0
by: carlton129 | last post by:
Hi! I am trying to copy the current form and subform to the clipboard with the click of a button so that I can paste it in another application. So far, I can get all of the Form info together into...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
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...

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.