473,785 Members | 2,879 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to make JS change input boxes?!?

Ok, here is my scenario: I need to input numbers using my handheld
IPAQ. I figured out how to create an online numeric keypad for
inputting numbers into an input field, what I need to know is how I
can have JS switch from one input field to another based on me
clicking in the empty box. Here is my code:

########## Start of code ############### ####
<html>

<head>
<title>${TITLE} </title>
<script>

function inpt(nm)
{
ibox = document.tester .number.value+" "+nm
document.tester .number.value = ibox;
}
</script>
</head>

<body>

<form name="tester" method=post>
<input type=text name="number">
<input type=text name="sales">
<input type=text name="budget">
<table border=1 cellpadding=1 cellspacing=1>
<tr vheight=20>
<td><input type=button value=" 1" onClick="inpt(1 );"></td>
<td><input type=button value=" 2" onClick="inpt(2 )"></td>
<td><input type=button value=" 3" onClick="inpt(3 )"></td>
</tr>
<tr>
<td><input type=button value=" 4" onClick="inpt(4 )"></td>
<td><input type=button value=" 5" onClick="inpt(5 )"></td>
<td><input type=button value=" 6" onClick="inpt(6 )"></td>
</tr>
<tr>
<td><input type=button value=" 7" onClick="inpt(7 )"></td>
<td><input type=button value=" 8" onClick="inpt(8 )"></td>
<td><input type=button value=" 9" onClick="inpt(9 )"></td>
</tr>
<tr>
<td><input type=button value=" 0" onClick="inpt(0 )"></td>
<td colspan=2><inpu t type=reset value="Reset"></td>
</tr>
</table>
</form>
</body>
</html>
########## End of code ############### ####

The above code by default will only input numbers into the "number"
input field. What I would like to do is tell JS to switch the input
to the "sales" or the "budget" field just by me clicking in the box.
I figure I can use the onFocus attribute and tried a few things but no
avail. Any help appreciated.

TIA,
Cranky
Nov 8 '06 #1
2 3108
Something like this should suite ur needs.
But i have not time to add a couple of if statemnets. So right now u
have to click even to the number box. But this can be fixed by 1-2
lines.

<html>

<head>
<title>${TITLE} </title>
<script>
var name;
function inpt(nm)
{

ibox = document.tester .elements[name].value+""+nm
document.tester .elements[name].value = ibox;

}

function foo(obj){
name=obj.name;

}

</script>
</head>

<body>

<form name="tester" method=post>
<input type=text name="number" onfocus="foo(th is)">
<input type=text name="sales" onfocus="foo(th is)">
<input type=text name="budget" onfocus="foo(th is)">
<table border=1 cellpadding=1 cellspacing=1>
<tr vheight=20>
<td><input type=button value=" 1" onClick="inpt(1 );"></td>
<td><input type=button value=" 2" onClick="inpt(2 )"></td>
<td><input type=button value=" 3" onClick="inpt(3 )"></td>
</tr>
<tr>
<td><input type=button value=" 4" onClick="inpt(4 )"></td>
<td><input type=button value=" 5" onClick="inpt(5 )"></td>
<td><input type=button value=" 6" onClick="inpt(6 )"></td>
</tr>
<tr>
<td><input type=button value=" 7" onClick="inpt(7 )"></td>
<td><input type=button value=" 8" onClick="inpt(8 )"></td>
<td><input type=button value=" 9" onClick="inpt(9 )"></td>
</tr>
<tr>
<td><input type=button value=" 0" onClick="inpt(0 )"></td>
<td colspan=2><inpu t type=reset value="Reset"></td>
</tr>
</table>
</form>
</body>
</html>
May be a bit later i will modify it.

GL.
Cranky wrote:
Ok, here is my scenario: I need to input numbers using my handheld
IPAQ. I figured out how to create an online numeric keypad for
inputting numbers into an input field, what I need to know is how I
can have JS switch from one input field to another based on me
clicking in the empty box. Here is my code:

########## Start of code ############### ####
<html>

<head>
<title>${TITLE} </title>
<script>

function inpt(nm)
{
ibox = document.tester .number.value+" "+nm
document.tester .number.value = ibox;
}
</script>
</head>

<body>

<form name="tester" method=post>
<input type=text name="number">
<input type=text name="sales">
<input type=text name="budget">
<table border=1 cellpadding=1 cellspacing=1>
<tr vheight=20>
<td><input type=button value=" 1" onClick="inpt(1 );"></td>
<td><input type=button value=" 2" onClick="inpt(2 )"></td>
<td><input type=button value=" 3" onClick="inpt(3 )"></td>
</tr>
<tr>
<td><input type=button value=" 4" onClick="inpt(4 )"></td>
<td><input type=button value=" 5" onClick="inpt(5 )"></td>
<td><input type=button value=" 6" onClick="inpt(6 )"></td>
</tr>
<tr>
<td><input type=button value=" 7" onClick="inpt(7 )"></td>
<td><input type=button value=" 8" onClick="inpt(8 )"></td>
<td><input type=button value=" 9" onClick="inpt(9 )"></td>
</tr>
<tr>
<td><input type=button value=" 0" onClick="inpt(0 )"></td>
<td colspan=2><inpu t type=reset value="Reset"></td>
</tr>
</table>
</form>
</body>
</html>
########## End of code ############### ####

The above code by default will only input numbers into the "number"
input field. What I would like to do is tell JS to switch the input
to the "sales" or the "budget" field just by me clicking in the box.
I figure I can use the onFocus attribute and tried a few things but no
avail. Any help appreciated.

TIA,
Cranky
Nov 8 '06 #2
ASM
Cranky a écrit :
Ok, here is my scenario: I need to input numbers using my handheld
IPAQ. I figured out how to create an online numeric keypad for
inputting numbers into an input field, what I need to know is how I
can have JS switch from one input field to another based on me
clicking in the empty box. Here is my code:

########## Start of code ############### ####
<html>

<head>
<title>${TITLE} </title>
<script>
function inpt(nm)
{
document.tester .number.value += ""+nm;
if(stock)
document.tester[stock].value=document .tester.number. value;
}
stock = false;
</script>
</head>

<body>

<form name="tester" method=post>
<input type=text name="number"
onclick="stock= false;">
<input type=text name="sales"
onclick="stock= this.name;this. value=number.va lue">
<input type=text name="budget"
onclick="stock= this.name;this. value=number.va lue">

--
ASM
Nov 8 '06 #3

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

Similar topics

2
14300
by: fish | last post by:
Hi, I have an HTML page with a FORM and some input fields. On the fields I wish to do validation as the punters change the field values. If they get it wrong, then I tell them and then wish to put the focus back to the offending field. ( It works if a use an 'onblur' event but not an 'onchange' )
3
5178
by: KathyB | last post by:
Hi, I'm trying to find a way to validate input text boxes where I don't know the names until the page is rendered. I've got 2 validate functions that fire with the onsubmit button of a "mini" form within the html document. When the Finish button is clicked, I need to check for any empty input boxes before loading the next aspx page...but it could be no boxes or five boxes, etc.? I've included my html output...if you have any ideas,...
3
5547
by: shortbackandsides.no | last post by:
Here's a working code fragment out of a form. One checkbox is checked the other isn't. When you change the status of one the other changes too. <input type="checkbox" name="nlbox1" value="9" checked onClick="document.signup.nlbox2.checked=!document.signup.nlbox2.checked;"> <input type="checkbox" name="nlbox2" value="8" onClick="document.signup.nlbox1.checked=!document.signup.nlbox1.checked;">
11
26327
by: Randell D. | last post by:
Folks, I have seven text boxes which will contain measurements - I would like the user to input their values in the order that I have listed the boxes. How can I therefore make an input type=text name=box2 a readonly while type=text name=box1 has a length of zero? This is for an intranet based application and I understand all the arguements and points that one has to consider in such that my server
4
21029
by: JohnSouth104 | last post by:
Hi I want to warn the user that changing the selected item in a pull-down will clear some data he has already entered in a file download box. I've tried using confirm() to return true or false with a line such as: onchange="return(confirm('proceed Yes or No')))" but it always stops the change.
3
1630
by: Ken McCrory | last post by:
I have a web form page (.aspx) with 95 label controls that I now need to be text boxes. Is there an easy way to change those to what I want using something like a find and replace or am I stuck "changing" each one by hand by deleting the label and dragging a text box in its place? Alternatively, the reason I think I need text boxes is that I need to pass the info in the labels to another page and its not working unless I use a text box....
7
7706
by: Vlad | last post by:
I have a problem of different date formats in an international study, where the data entry module and error checking module are delivered to the data collecting centres. Error checking module displays queries for edit specifications, many of them with dates. For exmple in Sweden, date format is YYYY-MM-DD, this are how dates are displayed; However, the input mask had been specified for tables as dd/mm/YYYY. This makes problematic using...
1
2612
by: SSG | last post by:
Dear All, I have 10 text boxes... first 5 text boxes e visible , rest of the 5 are hidden... once i clicked the button , the hidden boxes should be visble.. can anyone help me hpw to write script? Regards,
2
3262
by: pozitronic | last post by:
Hey all, I would like to do the following: I have 3 radio boxes. <input name="br" type="radio" value="first">Button1<br> <input name="br" type="radio" value="second">Button2<br> <input name="br" type="radio" value="third" />Button3<br>
0
9480
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10329
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10152
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10092
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8974
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5381
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4053
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2880
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.