- This topic has 3 replies, 2 voices, and was last updated 11 years, 11 months ago by will.
-
AuthorPosts
-
willMemberi have been trying to find a way to incorporate 2 values into a multiple select list. i have tryed to achieve this by using the first value as part of the text string and then utilizing a second value in the value string. This is to achieve a set discount on certain items when added to a shopping basket. My output page should show: 1. list of items @RRP 2. total@rrp 3. items at discount 4. total@ discount. 5.saving on purchases.
Here is a sample of the code for addition:
function b() {
var summaryb = “”;//multiple select list: get selected items as array
$(‘select[name=”list1″] :selected’).each(
function (i, selected) {summaryb += Number(parseInt($(selected).txt()));
});
$(‘#m1-test_2-textArea2’).text(summaryb);
yet even when recognizing the numerical elements of text Jquery cannot seem to perform numerical tasks with them. Therefore my questions:
1. is it possible to code it this way
2. is there any other way to have “2 values ” for a select list item
3. could an ID selector be used (i have no idea how to do this though)I apologize if this is already covered elsewhere but i could not find answers in the forums here or stack overflow.
Thanks
willMemberi’m really sorry but in posting this i noticed the error in my code and have fixed it (error was having VAR as “” instead of o) regardless if there is any information available about how to get decimals recognized with parseInt that would be useful thanks.
support-octavioMemberHi will,
I’ll coordinate with Wayne to discuss something that I have in mind that might be helful for your requirement to save two values for an select list item.
>regardless if there is any information available about how to get decimals recognized with parseInt that would be useful thanks.
Have you considered using parseFloat() ?
willMemberThanks for the speedy reply ill look into parsefloat() still learning jquery :).
-
AuthorPosts