Jump to content

has anyone seen something like this before $('#pwrcm:checkbox:checked')


yanith

Recommended Posts

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  :confused:

 

 

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

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")

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 :D

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.