facebook

parseInt in select lists

  1. MobiOne Archive
  2.  > 
  3. Getting Help – General
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #334470 Reply

    will
    Member

    i 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

    #334471 Reply

    will
    Member

    i’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.

    #334498 Reply

    Hi 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() ?

    #334545 Reply

    will
    Member

    Thanks for the speedy reply ill look into parsefloat() still learning jquery :).

Viewing 4 posts - 1 through 4 (of 4 total)
Reply To: parseInt in select lists

You must be logged in to post in the forum log in