250250 border-radius : 6px ;
251251 background : # fff ;
252252 }
253+
254+ /* Simulation controls */
255+ .simulation-controls {
256+ padding : 10px 12px ;
257+ background : # f0f0f0 ;
258+ border-bottom : 1px solid # ccc ;
259+ display : flex;
260+ align-items : center;
261+ }
262+
263+ .simulation-controls label {
264+ font-size : 16px ;
265+ font-weight : bold;
266+ min-width : auto;
267+ }
253268 </ style >
254269</ head >
255270< body >
@@ -353,6 +368,10 @@ <h3>Stocks and Bonds</h3>
353368 </section>
354369 <section class="strategy-section simulation">
355370 <h3>Simulation Table</h3>
371+ <div class="simulation-controls">
372+ <label for="simulationYears${ idx } ">Years to simulate:</label>
373+ <input type="number" id="simulationYears${ idx } " min="1" max="50" value="30" style="width: 60px; margin-left: 8px;">
374+ </div>
356375 <div id="strategyTable${ idx } " class="section-content"></div>
357376 </section>
358377 </div>
@@ -390,6 +409,16 @@ <h3>Simulation Table</h3>
390409 renderVerticalTabContent ( idx , selectedTab ) ;
391410 updateStrategyInputs ( idx ) ;
392411 runStrategySimulation ( idx , true ) ; // Skip individual graph updates during init
412+
413+ // Add event listener for simulation years input
414+ const simulationYearsInput = document . getElementById ( `simulationYears${ idx } ` ) ;
415+ if ( simulationYearsInput ) {
416+ simulationYearsInput . addEventListener ( 'input' , ( ) => {
417+ console . log ( '📝 Simulation years changed for idx:' , idx ) ;
418+ runStrategySimulation ( idx ) ;
419+ updateNetWorthGraph ( ) ;
420+ } ) ;
421+ }
393422}
394423
395424function renderStrategyTab ( idx ) {
@@ -734,7 +763,7 @@ <h3>Simulation Table</h3>
734763 monthlyRE = 1200 ;
735764 monthlyRemainder = 800 ;
736765 }
737- const result = simulateStrategy ( fixed , housePrice , initialDeposit , loanTerm , monthlyRE , monthlyRemainder , stocks , bonds ) ;
766+ const result = simulateStrategy ( fixed , housePrice , initialDeposit , loanTerm , monthlyRE , monthlyRemainder , stocks , bonds , idx ) ;
738767 strategyInputs [ idx ] . simRows = result ;
739768 renderStrategyTable ( idx , result ) ;
740769 // Only update the graph if not skipping
@@ -744,9 +773,10 @@ <h3>Simulation Table</h3>
744773 }
745774}
746775
747- function simulateStrategy ( fixed , housePrice , initialDeposit , loanTerm , monthlyRE , monthlyRemainder , stocks , bonds ) {
748- // Always simulate for 30 years regardless of loan term
749- const simulationYears = 30 ;
776+ function simulateStrategy ( fixed , housePrice , initialDeposit , loanTerm , monthlyRE , monthlyRemainder , stocks , bonds , strategyIdx ) {
777+ // Get simulation years from the input field, default to 30 if not found
778+ const simulationYearsInput = document . getElementById ( `simulationYears${ strategyIdx } ` ) ;
779+ const simulationYears = simulationYearsInput ? + simulationYearsInput . value : 30 ;
750780 let rows = [ ] ;
751781
752782 // Initial setup
0 commit comments