hi im literally a complete amateur at the but i was wondering how to write the information from a button e.g. A into a text box. I know it involves an onclick command but i just can figure it out. any help would be greatly appreciated below is what i already have: - <html>
-
<head>
-
<title>Page Title</title>
-
</head>
-
<body>
-
<h1>Table</h1>
-
<form>
-
<table border="1">
-
<tr>
-
-
<td><input type='button' value='A' /></td>
-
<td><input type='button' value='B' /></td>
-
</tr>
-
</table>
-
-
<input type="text" name="searchbox" size=15>
-
<div style="position:absolute; left:150px; top 150px;"></div>
-
-
</form>
-
<hr />
-
</body>
-
</html>
3 1987 Dormilich 8,658
Recognized Expert Moderator Expert
the procedure is quite simple:
write a function, where the value of the button is written to the target element’s value.
pass function to event handler - // put an id to the elements, so that you can access them easily
-
-
// write value to target
-
// "this" will later refer to the button
-
function passValue()
-
{
-
document.getElementById("target_input").value = this.value;
-
}
-
-
// register events (Button A, Button B)
-
document.getElementById("btnA").addEventListener("click", passValue, false);
-
document.getElementById("btnB").addEventListener("click", passValue, false);
-
// IE’s poor event handling requires a workaround, so google for the addEvent() crossbrowser solution
A simpler way could be - <input type='button' value='A' onclick="this.form.searchbox.value=this.value;" />
Dormilich 8,658
Recognized Expert Moderator Expert
"simple" is a matter of preference. suppose you want to change the target element…
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Aaron |
last post by:
Hello,
I have a small application that I need to save data from 7 text boxes in to
a csv file. This will entail btnNext_Click function that will create a new
csv file and enter the 7 data fields in the csv file; as well, each click on
next will return carriage to a new line.
Client does not what his data in an Access database(he hates Access with a
passion)--he feels more comfortable with Excel. This data will be no greater
than 1000...
|
by: Jennifer |
last post by:
On an ASP page I've got some code that is supposed to "export" data in
a grid to an Excel file. What I'm doing is writing all the data to a
text file, separating the fields by commas. Then I'll redirect the
user to a new page with the file that was just created.
Code:
Dim objFSO, objTextFile
Dim sRead, sReadLine, sReadAll
Const ForReading = 1, ForWriting = 2, ForAppending = 8
|
by: iwdu15 |
last post by:
how can i open a file i saved and place the info into different text boxes?
|
by: Marc |
last post by:
Hi,
I have a button on a form that, when pressed, adds additional user
defined buttons to the form. I need to be able to save the user
preferences and thought the best way would be to write the information
to a text file.
Can anyone supply the code on how to write the newly created buttons
name to a text file. As more than 1 new button may be created I want to
store the information for each new button on a new line then read the
|
by: hshah |
last post by:
Hello All,
I have created a .aspx page with 7 text boxes and a save button. On click event following code is fired. It save the property information to sql server and also generate a unique Id for that porperty and fatch that id and show it on that screen. I have created a .cs file for TrustConnectionString as below.
Can someone please help me or guide me, is this a good practice to write code? If not can you please help me how to...
| |
by: programming |
last post by:
Hi all,
i am having trouble trying to write a script to a txt file. I am
attempting to seperate each posted item with the deliminater '|', but
for some reason i am getting the following information written:
peri|jones||||Submit
Whereas the desired input should be as follows WITHOUT the submit
button been printed and on a NEW LINE:
|
by: mturner64 |
last post by:
I am developing an application using asp.net where a user can enter first name, last name, donation amount, date, et cetera. After the user enters the information and clicks submit, the information is written/stored into an Access 2007 database, which works well.
I am now wanting to allow a user to upload an image of themselves along with their text information and have that image stored in a field of the Access 2007 database.
I have...
|
by: L. Ximenes |
last post by:
Greetings,
I've recently been struggling with the idea of writing an XML document
based on user-submitted content using javascript.
Using various instances of document.write on a newly opened window I
succeeded in the task of outputting a perfectly valid XML document,
although I have been experiencing a few problems.
If I look at the source code of the new window, what I have is a
perfect XML document, such that if I copy the source...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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...
|
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...
| |
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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...
| |