473,541 Members | 14,784 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Trigger financial calculation on select change

17 New Member
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





Expand|Select|Wrap|Line Numbers
  1.  
  2. <SCRIPT language="JavaScript"> 
  3.     var Opt2;
  4.      var Opt1;
  5.  
  6.     function addfields() {
  7.          var category = parseInt(document.getElementById("category").value);
  8.          var family = parseInt(document.getElementById("family").value);
  9.          document.getElementById("textfield").value=category+family;
  10.          document.getElementById("textfield2").value=category+family;
  11.  
  12.          var value = category + family; 
  13.          document.form1.textfield.value = isNaN(value) ? '' : value;
  14.          document.form1.textfield2.value = isNaN(value) ? '' : value;
  15.      }
  16.  
  17.  function PopulateSelect2(){
  18.      Opt1=document.form1.category;
  19.     Opt2=document.form1.family;
  20.     Opt2.options.length=0;
  21.     Opt2.options[Opt2.options.length]=new Option("0", 0);
  22.  
  23.     switch(Opt1.selectedIndex)
  24.     {
  25.         case 1:
  26.               Opt2.options[Opt2.options.length]=new Option("1", 40);
  27.             Opt2.options[Opt2.options.length]=new Option("2", 80);
  28.             Opt2.options[Opt2.options.length]=new Option("3", 120);
  29.             break;   
  30.         case 2:
  31.             Opt2.options[Opt2.options.length]=new Option("1", 40); break; 
  32.         case 3:
  33.             break;
  34.         case 4:
  35.             Opt2.options[Opt2.options.length]=new Option("1", 40);
  36.             Opt2.options[Opt2.options.length]=new Option("2", 80);
  37.             Opt2.options[Opt2.options.length]=new Option("3", 120);
  38.             break;
  39.         }
  40.     }
  41.  
  42.     function React2Select2()
  43.     {
  44.         var value;
  45.  
  46.         Opt2=document.form1.family;
  47.         document.getElementById('F1').style.display="none";
  48.         document.getElementById('F2').style.display="none";
  49.         document.getElementById('F3').style.display="none";
  50.         document.getElementById('Ft1').style.display="none";
  51.         document.getElementById('Ft2').style.display="none";
  52.         document.getElementById('Ft3').style.display="none";
  53.         switch(Opt2.selectedIndex)
  54.         {
  55.             case 1:
  56.                 document.getElementById('F1').style.display="block";
  57.                 document.getElementById('Ft1').style.display="block";
  58.                 break;   
  59.             case 2:
  60.                 document.getElementById('F1').style.display="block";
  61.                 document.getElementById('F2').style.display="block";
  62.                 document.getElementById('Ft1').style.display="block";
  63.                 document.getElementById('Ft2').style.display="block";
  64.                 break;
  65.             case 3:
  66.                 document.getElementById('F1').style.display="block";
  67.                 document.getElementById('F2').style.display="block";
  68.                 document.getElementById('F3').style.display="block";
  69.                 document.getElementById('Ft1').style.display="block";
  70.                 document.getElementById('Ft2').style.display="block";
  71.                 document.getElementById('Ft3').style.display="block";
  72.                 break;
  73.         }
  74.  
  75.         value=parseFloat(document.form1.family.value) + parseFloat(document.form1.category.value);
  76.         document.form1.textfield.value = isNaN(value) ? '' : value;
  77.          document.form1.textfield2.value = isNaN(value) ? '' : value;
  78.     }    
  79.  
  80. </SCRIPT> 
  81.  

Expand|Select|Wrap|Line Numbers
  1. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  2. <title>Untitled Document</title>
  3. <style type="text/css">
  4. <!--
  5. .style1 {color: #FF0000}
  6. .style3 {color: #FF0000; font-size: small; }
  7. .style4 {font-size: 12px}
  8. .style5 {font-size: 18px}
  9. -->
  10. </style>
  11. </head>
  12.  
  13. <body>
  14. <form id="form1" name="form1" method="post" action="">
  15.   <table width="700" border="1">
  16.     <tr>
  17.       <td><div align="right">Category</div></td>
  18.       <td><select name="category" id="category"  onchange="PopulateSelect2()" >
  19.         <option>Select a Category</option>
  20.         <option value="85">OMEA Member</option>
  21.         <option value="25">OCMEA Member</option>
  22.         <option value="45">Saturday Only</option>
  23.         <option value="200">Non Member</option>
  24.       </select></td>
  25.       <td>&nbsp;</td>
  26.     </tr>
  27.     <tr>
  28.       <td><div align="right">Family Attending</div></td>
  29.       <td>
  30.       <select name="family" id="family" onchange="React2Select2();" onclick="React2Select2();">
  31.     </select>
  32.       </td>
  33.       <td>&nbsp;</td>
  34.     </tr>
  35.     <tr>
  36.       <td><div align="right">Total Fees</div></td>
  37.       <td bgcolor="#FFFFFF"><span class="style3"> $</span>
  38.         <input name="textfield" type="text" disabled="disabled" class="style1" id="textfield" /></td>
  39.       <td>&nbsp;</td>
  40.     </tr>
  41.     <tr>
  42.       <td valign="top">
  43.           <div align="right" id="F1" style="display:none;" >Family Member1</span></div>
  44.  
  45.             <div align="right" id="F2" style="display:none;">Family Member2</span></div>
  46.  
  47.           <div align="right" id="F3" style="display:none;">Family Member3</span></div>
  48. &nbsp;     </td>
  49.       <td bgcolor="#FFFFFF">
  50.           <div id="Ft1" style="display:none;"><input name="Family1" type="text" id="Family1" /></div>
  51.  
  52.             <div id="Ft2" style="display:none;"><input name="Family2" type="text" id="Family2" /></div>
  53.  
  54.           <div id="Ft3" style="display:none;"><input name="Family3" type="text" id="Family3" /></div>
  55.           &nbsp;
  56.       </td>
  57.       <td>&nbsp;</td>
  58.     </tr>
  59.     <tr>
  60.       <td>&nbsp;</td>
  61.       <td bgcolor="#FFFFFF"><input type="text" name="textfield2" id="textfield2" DISABLED /></td>
  62.       <td>&nbsp;</td>
  63.     </tr>
  64.   </table>
  65.   <p>&nbsp;</p>
  66. </form>
  67. </body>
  68. </html>
  69.  
  70.  
Sep 8 '07 #1
4 2414
gregincolumbus
17 New Member
Anyone able to help me on this? Please?

Thanks

Greg
Sep 8 '07 #2
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?
Sep 8 '07 #3
gregincolumbus
17 New Member
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
Sep 8 '07 #4
pbmods
5,821 Recognized Expert Expert
Heya, Greg.

Oh goodie.

Alrightey. On this line here:
Expand|Select|Wrap|Line Numbers
  1. <td><select name="category" id="category"  onchange="PopulateSelect2()" >
  2.  
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.:

Expand|Select|Wrap|Line Numbers
  1. <td><select name="category" id="category"  onchange="PopulateSelect2(); RunFinancialCalculations();" >
  2.  
That should get you started; we'll go from there :)
Sep 8 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

6
3433
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')
8
8586
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...
3
21464
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...
6
8268
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,...
1
15392
by: shottarum | last post by:
I currently have 2 tables as follows: CREATE TABLE . ( mhan8 int, mhac02 varchar(5), mhmot varchar(5), mhupmj int )
7
1759
by: rkrueger | last post by:
Given the following 3 Tables: CREATE TABLE ( NOT NULL , NOT NULL CONSTRAINT DEFAULT (getdate()), NULL , CONSTRAINT PRIMARY KEY CLUSTERED (
2
7370
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,...
2
2379
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
1
7258
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,...
0
7372
marktang
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...
0
7316
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...
0
7549
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. ...
0
7711
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...
1
7306
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...
1
5231
isladogs
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...
0
3366
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...
1
937
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
605
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...

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.