yanith Posted December 7, 2011 Share Posted December 7, 2011 hello guys, this is my first post and I had been looking for some help with a php/javascript form that i was passed down. the form is a 93 files mess, however i got to understand the functions and how variables pass from file to file. so i was able to make most of the changes except one In the calculator.js I have a function that creates the subtotals and displays them on the screen. I can't show the entire function cuz is over 600 lines but i'll explain my situation below I have a drop-down selection box that need to be add-up in the example code below. for radio buttons classes are used to group the price, you can see it in $('.hsis:radio:checked') for check boxes ids are used to display the price $('#pwrcm:checkbox:checked') however in a code with similar syntax i need to show the price of each drop down selections. how could it be done? I tried $('#hdtv:select:selected') and updated the variable names but no luck function addup_subtotals() { var hsi_subtotal = $('.hsis:radio:checked').val(); if(isNaN(hsi_subtotal)) {hsi_subtotal=0;} else {hsi_subtotal=parseFloat(hsi_subtotal);} var pwrcm_subtotal = $('#pwrcm:checkbox:checked').val(); if(isNaN(pwrcm_subtotal)) {pwrcm_subtotal=0;} else {pwrcm_subtotal=parseFloat(pwrcm_subtotal);} has anyone seen something like this before Quote Link to comment Share on other sites More sharing options...
requinix Posted December 7, 2011 Share Posted December 7, 2011 Those are jQuery selectors. http://api.jquery.com/ Note how there is no :select. Checkboxes are one element, but "dropdowns" use two: a SELECT and its OPTION children. Either grab the .val() from the SELECT $("select#pwrcm").val() or find the selected OPTION $("select#pwrcm option:selected") Quote Link to comment Share on other sites More sharing options...
yanith Posted December 8, 2011 Author Share Posted December 8, 2011 Thanks requinix! while id didn't exactly work you point me in the right direction, the link really help me understand more about it. I really appreciate it. I end up creating two extra variables to multiple the unit cost times times the amount of units requested. and passing those to a regular variable. I end up using this: var stb_db_total = $('#stb_db_total').val(); if (isNaN(stb_db_total)) {stb_db_total=0;} else {stb_db_total=parseFloat(stb_db_total);} Thanks a lot this puppy is solved Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.