Kano
Members-
Posts
76 -
Joined
-
Last visited
Never
Profile Information
-
Gender
Female
-
Location
England
Kano's Achievements
Member (2/5)
0
Reputation
-
Hi there, how does javascript add to a input text box the value (1.05) when a checkbox is checked and the value (0.00) when not checked, thanks for any help.
-
Hi there, Yes I forgot to include the php tags in the code i listed to save time. So that is not the problem. The code I listed is so that the form will get totals from all the item totals onclick in a for loop. But like all Javascript it never seems to work properly.
-
Hi there, I need help with this javascript because it does not work as far i can tell? <SCRIPT> function gettotals(obj, rowcnt){ var stot = 0;var temp = 0;var ff = 0; for (var cnt = 1; cnt <= rowcnt; cnt++){ temp = (obj.form.getElementById("price_"+cnt).value) * (obj.form.getElementById("qty_"+cnt).value); stot += temp; } ff = stot.toFixed(2); obj.form.elements['s_total'].value = ff; } </SCRIPT> <BODY> .... <?php while(blarb){... <input type = 'text' id = 'price_$rowcnt' name = 'price_$wsi_id' value = '$wsi_price' ..... <select id = 'qty_$rowcnt' name='qty_$wsi_id' ....... .....} <input type="text" name="s_total"..... <input type='button' value = 'Get Totals' onclick='gettotals(this, \"$rowcnt\")' /> Thanks for any help..
-
Hi there, Wanting to add a button to my form so when the user selects it the grand total input value = all input values whos name is index of "subtotal_". Have tried many other ways of achieving this but with no success so I think this is the best way to get the totals. The subtotal_ is a value gotten using javascript (price * qty(<select>). Can any one help? thanks.
-
HI there, Can someone help me please, this code works fine but I wish to add a function which adds all the <total_$wsi_id> values up and creates a grand total?? <script> function calc(obj, wsi_id) // function to create total of each order line { var ans = (obj.form.elements['price_'+wsi_id].value) * (obj.form.elements['qty_'+wsi_id].value); var res = ans.toFixed(2); obj.form.elements['total_'+wsi_id].value = res; } </script> <body> ..... while($row_getwsi = mysql_fetch_array($sqlres_getwsi)) { extract($row_getwsi); // create order line echo " <td> <input type = 'text' name = 'price_$wsi_id' value = '$wsi_price' readonly =' readonly' size = '6' maxsize = '7' /> </td> <td> <select name = 'qty_$wsi_id' onchange = 'calc(this, \"$wsi_id\")'>"; // create order line total for($selectcnt=0;$selectcnt<=$wsi_qty;$selectcnt++) { echo "<option value='$selectcnt'"; if($_SESSION[$wsi_id] == $selectcnt) { echo "selected='selected'"; } echo">$selectcnt</option>"; } echo "</select></td>"; echo"<td>$wsi_id</td> <td>$wsi_dim</td> <td><input type = 'text' name = 'total_$wsi_id' readonly = 'readonly' /> </td>"; .... <tr><td>Grand Total</td><td><input type="text" name="g_total" /></td></tr> // I wish this part to total all the order lines. .... thanks.
-
Hi there, Can someone help me please. I have an order form in which PHP freaks kindly helped me build a while back, but I am having problems with including a grand total to the form. Each line of the form has a sub-total which javascript works out by * the qty (select tag) with the price, the javascript is 'onchange' on the select tag. Now i want the forms grand total input box to = all the sub-total input boxes. Would this be done within the same javascript function on the select tags (i.e every time there is a change work out grand total)? The sub-totals have a name="subtotal_$wsi_id" (i.e. sub-totals have an index of subtotal_) The grand-total has a name="grandtotal" Many thanks.
-
hi there, Was wondering if someone new how to stop text in a <td> from adjusting: This is text on page. to this: This is text on page. thanks.
-
[SOLVED] using input id instead of name when calculating forms
Kano replied to Kano's topic in Javascript Help
Hi there again Fenway, Problem solved - what i have do is changed the onchange = 'calc(this, \'$wsi_id\')' TO onchange = 'calc(this, \"$wsi_id\")' And it likes it, don't know why but it does?? Thanks for your time. -
[SOLVED] using input id instead of name when calculating forms
Kano replied to Kano's topic in Javascript Help
Sussed it!!!! Woooooooooo Added attribute value="0" ect... to the options in the select, now IE likes that?? Thanks for your help Fenway. I am sure its not the end... -
[SOLVED] using input id instead of name when calculating forms
Kano replied to Kano's topic in Javascript Help
I have added the toFixed function to round to 2 decimals but still same problem in IE (0.00), FireFox is fine. -
[SOLVED] using input id instead of name when calculating forms
Kano replied to Kano's topic in Javascript Help
Hi there, You are right is does work in FireFox, try it in IE!! Anyone know why it gives the result as 0 in IE?? thanks. -
[SOLVED] using input id instead of name when calculating forms
Kano replied to Kano's topic in Javascript Help
Hi there, I have recreated this problem in static HTML to see if I can find any problems. The problem I am now getting at the moment is onchange the total is calculated to 0 every time, here is the code: <script> function gogo (obj) { obj.form.elements['total_VB001'].value = (obj.form.elements['price_VB001'].value) * (obj.form.elements['qty_VB001'].value); return; } </script> <form id="orderform" name="orderform" method="post" action=""> <table><tr><td> <input type="text" name="price_VB001" value="122.99" readonly="readonly" /></td><td> <select name="qty_VB001" onchange="gogo(this)"> <option selected="selected">0</option> <option>1</option> <option>2</option> <option>3</option> <option>4</option> <option>5</option> </select></td><td> <input type="text" name="total_VB001" readonly="readonly" /></td></tr> </table> </form> Any ideas what is wrong with this? Thanks. -
[SOLVED] using input id instead of name when calculating forms
Kano replied to Kano's topic in Javascript Help
Hi there Fenway, I take it 'obj' holds 'this' which means this 'document'? And when the select input changes it then reads the function and adds the total of the sum to the input box total. Should there be any brackets around the sum? Should there be a semi-colon after the sum? Should there be <!-- --> in the <script>? Maybe I will run the script through FireFox instead of IE and see what happens. It looks like it should work? I cannot see any reason to suggest otherwise? -
[SOLVED] using input id instead of name when calculating forms
Kano replied to Kano's topic in Javascript Help
Hi there fenway, No JS errors. It just does not register anything?