I am new to prototype/javascript as my background is in php. I am trying to have a 2 x 2 grid of text input blocks that are summed to the right & below. Ajax is ment to update on change by re-formatting whatever was input and all the totals. A relevant section of my efforts found below.
php - <table width='400' border='1' align='center'> <tr> <td style='text-align:right'> <div id='A1'> <input type='text' name='A1' tabindex='11' style='text- align:right;width:127px;' value='<?php echo number_format($A1,2) ?>' onChange="sendRequest('edit.php')" /> </div> </td> <td>+</td> <td style='text-align:right'> <div id='A2'> <input type='text' name='A2' tabindex='21' style='text- align:right;width:127px;' value='<?php echo number_format($A2,2) ?>' onChange="sendRequest('edit.php')" /> </div> </td> <td>=</td> <td style='text-align:right'><?php echo number_format($A1 + $A2,2) ?></td> </tr> & the javascript - function sendRequest(url) { new Ajax.Request(url,{ method: 'post', parameters: $('mtrade').serialize(true), onComplete: showResponse, }); } function showResponse(value) { $(value).innerHTML = Math.round(value.responseText * 100) / 100; if ('A1') { $(A1).innerHTML = Math.round($F(A1) * 100) / 100; $(C1).innerHTML = Math.round($F(A1)+$(B1).value * 100) / 100; $(A3).innerHTML = Math.round($F(A1)+$(A2).value * 100) / 100; } if ('A2') { $(A2).innerHTML = Math.round($F(A2) * 100) / 100; $(C2).innerHTML = Math.round($F(A2)+$(B2).value * 100) / 100; $(A3).innerHTML = Math.round($F(A2)+$(A1).value * 100) / 100; } if ('B1') { $(B1).innerHTML = Math.round($F(B1) * 100) / 100; $(C1).innerHTML = Math.round($F(B1)+$(A1).value * 100) / 100; $(B3).innerHTML = Math.round($F(B1)+$(B2).value * 100) / 100; } if ('B2') { $(B2).innerHTML = Math.round($F(B2) * 100) / 100; $(C2).innerHTML = Math.round($F(B2)+$(A2).value * 100) / 100; $(B3).innerHTML = Math.round($F(B2)+$(B1).value * 100) / 100; } Now is the javascript meant to do the updating or the called edit.php? There is probably a simpler way to this too. Thanks in advance. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~----------~----~----~----~------~----~------~--~---