I have a web page that displays multiple records for a company. The
input text boxes that display my data are created dynamically. I'm
creating these input boxes dynamically because the number of records
for each company varies. The name of each input box increments by one
for each record (Ex: A1, B1, C1 | A2, B2, C2, etc..)
On my web page the user will enter in a number into the
txtGrossPayroll (some number) input box. I have added an
OnKeyDown="Comp utePremium()" and an OnKeyUp="Comput ePremium()" inside
my input boxes. When the user begins to type in a number the following
script runs and displays the premium inside the txtPremium(some number)
input box.
<script type="text/javascript" language="JavaS cript">
<!--
function ComputePremium( ) {
document.Schedu leForm.txtPremi um1.value =
Math.round((doc ument.ScheduleF orm.txtRate1.va lue *
(document.Sched uleForm.txtGros sPayroll1.value / 100)), 0);
}
// -->
</script>
Currently, I have the script so that it will only run for my 1st row of
records. Can the script be modified so that it is intelligent enough
to know the correct input box name to use? If so how?
I'm not very familiar with JavaScripts; sorry if this is something that
is very easy to do.
Thanks!
CR Junk 3 4296 cr****@earthlin k.net wrote: ... . The input text boxes that display my data are created dynamically.
Client-side or server-side?
I'm creating these input boxes dynamically because the number of records for each company varies. The name of each input box increments by one for each record (Ex: A1, B1, C1 | A2, B2, C2, etc..)
On my web page the user will enter in a number into the txtGrossPayroll (some number) input box. I have added an OnKeyDown="Comp utePremium()" and an OnKeyUp="Comput ePremium()"
Two calculations per key press?
inside my input boxes. When the user begins to type in a number the following script runs and displays the premium inside the txtPremium(some number) input box.
<script type="text/javascript" language="JavaS cript"> <!--
This "hide scripts form older browsers" stuff is superfluous.
function ComputePremium( ) { document.Schedu leForm.txtPremi um1.value = Math.round((doc ument.ScheduleF orm.txtRate1.va lue * (document.Sched uleForm.txtGros sPayroll1.value / 100)), 0);
^
What is the zero for?
} // --> </script>
Currently, I have the script so that it will only run for my 1st row of records.
Because you have hard-coded the form control name.
Can the script be modified so that it is intelligent enough to know the correct input box name to use?
Yes.
If so how?
By providing the row information as a parameter to the function call, in
some form, and then using bracket notation to reference the form
controls in the correct row.
I'm not very familiar with JavaScripts; sorry if this is something that is very easy to do.
It is very easy to do, but how it is specifically done depends on the
HTML being scripted.
Richard.
Richard Cornford wrote: Client-side or server-side?
The input boxes are being created on the server-side.
Two calculations per key press?
I didn't think that that I needed to have OnKeyUp and OnKeyDown, but a
script that I used as a reference used both events. I went with how
they had created their script. Will either one of these accomplish
what I want?
What is the zero for?
Sorry about that. This is old code that I forgot to remove from the
desktop app that I'm converting and moving online.
By providing the row information as a parameter to the function call, in
some form, and then using bracket notation to reference the form
controls in the correct row.
Since I'm creating each input box on the server-side, I now see how I
can pass the row number to the function when the server is generating
the HTML. Can you provide an example of what the syntax looks like for
using bracket notation when referencing the form controls in the
formula?
Thanks for your help Richard!
CR Junk
Hi Richard,
I continued playing around with my function and came up with the
following:
function ComputePremium( i) {
document.Schedu leForm["txtPremium " + i].value =
Math.round((doc ument.ScheduleF orm["txtRate" + i].value *
(document.Sched uleForm["txtGrossPayrol l" + i].value / 100)));
}
So far, it seems to be working correctly. Is this what you were
refering to when you mentioned bracket notation.
Thanks,
CR Junk This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: utterberg |
last post by:
Can anyone help me with this problem?
I dynamically creates several textboxes using a placeholder. This works
fine. But is there a way for me to loop through theese textboxes and
retrive its value when clicking a button?
The code I'm working with:
aspx-page
<form id="Form1" method="post" runat="server">
<asp:PlaceHolder ID="EDCTextBoxes" Runat="server" />
|
by: Jack Johnston |
last post by:
Hi there,
I am dynamically created a table at runtime on an aspx form. The last
cell of each row contains a TextBox in which the user will enter
numeric values into.
Each textbox I create is given a name such as myTextBox0, myTextBox1,
... etc Basically the index of the loop that creates the table is
appended to the end of each TextBox name (ID).
|
by: JaM |
last post by:
Hi all,
I have created a gridview vith dynamic textbox columns (they are in
variable number, it depends on what things I select from database)
aspx code:
__________________________________________
<asp:GridView AutoGenerateColumns="false" ID="GridView2" Runat="server"
<Columns>
|
by: Silver Oak |
last post by:
I have a DataGrid in which one of the columns is TemplateColumn that was
created dynamically using iTemplate. I would like to have multi-row editing
capability on the DataGrid. I'm trying to follow the example in MSDN
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/vbtchTopQuestionsAboutASPNETDataGridServerControl.asp
Section "Editing Multiple Rows at once".
I would like to follow the second solution...
|
by: HHAAPPYY |
last post by:
Hi
I am trying to pass value of the textbox along with another value to the query string.
when i am retriving the txtbox value it always shows me null,
my senario is like this
On my page div_admin.asp i have following things.<%
Dim page, content,console,banner,navbar
| |
by: raghulvarma |
last post by:
I have created only one object for the textbox and that particular textbox is being repeated as many times I want.But if I want to add the values in the database from each and every textbox which have been dynamically created how should I do that? I have uesd dropdown box to get the number of textboxes to be displayed and used panel to display them.
Let me explain with my real time scenario , if customer-A has 2 telephone lines and...
|
by: foss |
last post by:
I have got a Html form with a table.
The table contains textfield and a button.
When I click the button I want another textfiled to be created.
(I have done till here)
The problem is that I want the new textfield to be created in the same cell (within <TD> tag) where the first textfield is. I have tried to use <span> tag so as to force the new textfield to be created in the table cell. But I could not succeed.
My code goes as follows:
...
|
by: pooja8389 |
last post by:
Good evening..
how can i save the value of dynamically created textbox in data base
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
|
by: pooja8389 |
last post by:
good evening...
how can store the text value of dynamically created textbox in database.
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
|
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: 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,...
| |
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: 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: 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: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |