I am trying to get the financial calculation on this to trigger whenever there is a change to select1. Right now, the user has to click on select2 to trigger the changes.
Ideally, a change of select1
1. trigger the population of select2 (and set it initially to 0)
2. make the text fields disappear
3. trigger the financial calculation to reflect the select1 choice.
Any help would be greatly appeciated !
Greg -
-
<SCRIPT language="JavaScript">
-
var Opt2;
-
var Opt1;
-
-
function addfields() {
-
var category = parseInt(document.getElementById("category").value);
-
var family = parseInt(document.getElementById("family").value);
-
document.getElementById("textfield").value=category+family;
-
document.getElementById("textfield2").value=category+family;
-
-
var value = category + family;
-
document.form1.textfield.value = isNaN(value) ? '' : value;
-
document.form1.textfield2.value = isNaN(value) ? '' : value;
-
}
-
-
function PopulateSelect2(){
-
Opt1=document.form1.category;
-
Opt2=document.form1.family;
-
Opt2.options.length=0;
-
Opt2.options[Opt2.options.length]=new Option("0", 0);
-
-
switch(Opt1.selectedIndex)
-
{
-
case 1:
-
Opt2.options[Opt2.options.length]=new Option("1", 40);
-
Opt2.options[Opt2.options.length]=new Option("2", 80);
-
Opt2.options[Opt2.options.length]=new Option("3", 120);
-
break;
-
case 2:
-
Opt2.options[Opt2.options.length]=new Option("1", 40); break;
-
case 3:
-
break;
-
case 4:
-
Opt2.options[Opt2.options.length]=new Option("1", 40);
-
Opt2.options[Opt2.options.length]=new Option("2", 80);
-
Opt2.options[Opt2.options.length]=new Option("3", 120);
-
break;
-
}
-
}
-
-
function React2Select2()
-
{
-
var value;
-
-
Opt2=document.form1.family;
-
document.getElementById('F1').style.display="none";
-
document.getElementById('F2').style.display="none";
-
document.getElementById('F3').style.display="none";
-
document.getElementById('Ft1').style.display="none";
-
document.getElementById('Ft2').style.display="none";
-
document.getElementById('Ft3').style.display="none";
-
switch(Opt2.selectedIndex)
-
{
-
case 1:
-
document.getElementById('F1').style.display="block";
-
document.getElementById('Ft1').style.display="block";
-
break;
-
case 2:
-
document.getElementById('F1').style.display="block";
-
document.getElementById('F2').style.display="block";
-
document.getElementById('Ft1').style.display="block";
-
document.getElementById('Ft2').style.display="block";
-
break;
-
case 3:
-
document.getElementById('F1').style.display="block";
-
document.getElementById('F2').style.display="block";
-
document.getElementById('F3').style.display="block";
-
document.getElementById('Ft1').style.display="block";
-
document.getElementById('Ft2').style.display="block";
-
document.getElementById('Ft3').style.display="block";
-
break;
-
}
-
-
value=parseFloat(document.form1.family.value) + parseFloat(document.form1.category.value);
-
document.form1.textfield.value = isNaN(value) ? '' : value;
-
document.form1.textfield2.value = isNaN(value) ? '' : value;
-
}
-
-
</SCRIPT>
-
-
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
-
<title>Untitled Document</title>
-
<style type="text/css">
-
<!--
-
.style1 {color: #FF0000}
-
.style3 {color: #FF0000; font-size: small; }
-
.style4 {font-size: 12px}
-
.style5 {font-size: 18px}
-
-->
-
</style>
-
</head>
-
-
<body>
-
<form id="form1" name="form1" method="post" action="">
-
<table width="700" border="1">
-
<tr>
-
<td><div align="right">Category</div></td>
-
<td><select name="category" id="category" onchange="PopulateSelect2()" >
-
<option>Select a Category</option>
-
<option value="85">OMEA Member</option>
-
<option value="25">OCMEA Member</option>
-
<option value="45">Saturday Only</option>
-
<option value="200">Non Member</option>
-
</select></td>
-
<td> </td>
-
</tr>
-
<tr>
-
<td><div align="right">Family Attending</div></td>
-
<td>
-
<select name="family" id="family" onchange="React2Select2();" onclick="React2Select2();">
-
</select>
-
</td>
-
<td> </td>
-
</tr>
-
<tr>
-
<td><div align="right">Total Fees</div></td>
-
<td bgcolor="#FFFFFF"><span class="style3"> $</span>
-
<input name="textfield" type="text" disabled="disabled" class="style1" id="textfield" /></td>
-
<td> </td>
-
</tr>
-
<tr>
-
<td valign="top">
-
<div align="right" id="F1" style="display:none;" >Family Member1</span></div>
-
-
<div align="right" id="F2" style="display:none;">Family Member2</span></div>
-
-
<div align="right" id="F3" style="display:none;">Family Member3</span></div>
-
</td>
-
<td bgcolor="#FFFFFF">
-
<div id="Ft1" style="display:none;"><input name="Family1" type="text" id="Family1" /></div>
-
-
<div id="Ft2" style="display:none;"><input name="Family2" type="text" id="Family2" /></div>
-
-
<div id="Ft3" style="display:none;"><input name="Family3" type="text" id="Family3" /></div>
-
-
</td>
-
<td> </td>
-
</tr>
-
<tr>
-
<td> </td>
-
<td bgcolor="#FFFFFF"><input type="text" name="textfield2" id="textfield2" DISABLED /></td>
-
<td> </td>
-
</tr>
-
</table>
-
<p> </p>
-
</form>
-
</body>
-
</html>
-
-
4 2414
Anyone able to help me on this? Please?
Thanks
Greg
pbmods 5,821
Recognized Expert Expert
Heya, Greg.
First off:
[CODE=javascript]
JavaScript code goes here.
[/CODE]
and
[CODE=html]
HTML code goes here.
[/CODE]
and so on.
To answer your question, can you add the function call to the onchange attribute for your select element?
Hi
Thanks for the response..sorry about the code tags...thought I was doing it right....will do better next time :)
I am a newbie to javascript. The code I sent was written by somebody else who I paid a small deposit to write it but he never finished it completely. I was supposed to pay the balance when the work was completed.
I have tried contacting him but have gotten no response...so I am trying to get this thing finished and out the door..I am on a tight timeline for a project I volunteered to do.
How do I add the function call to the onchange attribute?
Sorry for all the newbie questions.
Thanks
Greg
pbmods 5,821
Recognized Expert Expert
Heya, Greg.
Oh goodie.
Alrightey. On this line here: -
<td><select name="category" id="category" onchange="PopulateSelect2()" >
-
you're setting the onchange handler to 'PopulateSelect2()'. In other words, when the selected value changes, the browser will automatically call PopulateSelect2().
All you need to do from here is create the function that does all the stuff you need it to and add it to the event handler, e.g.: -
<td><select name="category" id="category" onchange="PopulateSelect2(); RunFinancialCalculations();" >
-
That should get you started; we'll go from there :)
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Dave C. |
last post by:
Hello,
I have created the following trigger:
CREATE TRIGGER tr_UDFTest ON UserDefinedFields FOR INSERT, UPDATE
AS
DECLARE @foobar varchar(100)
SELECT @foobar= foobar FROM inserted
IF ( @foobar = 'foobar') INSERT INTO LogTable (LogText) values ('Found foobar')
|
by: Jason |
last post by:
I have a table that matches up Securities and Exchanges. Individual
securities can belong on multiple exchanges. One of the columns, named
PrimaryExchangeFlag, indicates if a particular exchange is the primary
exchange for that symbol. Each symbol can only have one primary
exchange.
I am trying to write a insert/update/delete trigger that...
|
by: Mike |
last post by:
I have never written a trigger before, but I have a couple of uses for
them now so I am trying. I have a view that I created and I want to
have this trigger, run anytime the view is run. I don't know if my
problem is with the trigger or permissions on the view, right now I
have given everyone permission to select and update on the view (just...
|
by: John Bentley |
last post by:
John Bentley writes at this level:
If we think about our savings accounts then division never comes in (as far as
I can see). We deposit and withdraw exact amounts most of the time. Occasionaly
we get an interest payment. Unless the bank is cruel to its developers the
interest figure will be able to be exactly represented by a computer,...
|
by: shottarum |
last post by:
I currently have 2 tables as follows:
CREATE TABLE .
(
mhan8 int,
mhac02 varchar(5),
mhmot varchar(5),
mhupmj int
)
| |
by: rkrueger |
last post by:
Given the following 3 Tables:
CREATE TABLE (
NOT NULL ,
NOT NULL CONSTRAINT
DEFAULT (getdate()),
NULL ,
CONSTRAINT PRIMARY KEY CLUSTERED
(
|
by: IntraRELY |
last post by:
I know this isnt really a VB question per say, but is what I am developing
in VB.NET and Excel is the only place that has provided direction. I wanted
to ask the public if perhaps you could lend me a hand a point me into the
right direction if there is someone who has had experiance with this. By all
means if you know a better place to ask,...
|
by: dean.cochrane |
last post by:
I have inherited a large application.
I have a table which contains a hierarchy, like this
CREATE TABLE sample_table(
sample_id int NOT NULL
parent_sample_id int NOT NULL
....lots of other cols...)
DELETEs on all tables are handled by the front end code, which just
|
by: djdevx |
last post by:
Dear all PostgreSQL xperts!
Hi, I am newbie in PostgreSQL. I am currently developing an app that use PostgreSQL as a BackEnd Database.
Now I am having problem with the function trigger since last week.
Here's the case:
create table nr_tr (tr_type character(3), period character(6), nr_tr integer);
create table h_trsale(nr_tr integer,...
|
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...
|
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...
| |
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. ...
|
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...
|
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...
|
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...
|
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...
|
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...
| |