Member Avatar for diafol

The multiple attribute works with email and file input types only.

You still didn't answered in any of my questions , you still didn't explained what you are doing. I will play the mentalist again (but I don't have enough clues) as an exception. Is this the question (or something very similar), if isn't explain where your logic is different?

“I have a system that each user has an amount of points , it can search users with an auto complete method select the users he / she likes and then insert a number of points that want to give to selected users. Each user has a different factor of power from 0 to 1 (with negative meaning) for example if a user has powerFactor 0 when he gives 20 points to a user then none point will be subtracted from hers / his points , if has 1 then 20 points will be subtracted (if he / she has 0.5 then 10 points will be subtracted). How can all that to be done only with AJAX calls and notice the user with the number of points to be subtracted before he actually confirm this ? ”

I want to multiply three parameters and get a result. (xyw = z)

The first (and thats my problem) is an input type field that autocompletes users names. The field returns the ids as an array <input type="hidden" value="selected_ids" name="selected_ids[]" multiple="yes" id="selected_ids" />
e.g. 1,4,7,23 and i want to count those ids for example 1,4,7,23 makes 4

The second is an input type="number" which the user provides an integer number as a value (1,2,3,4,5,6 etc) Lets say puts the number 3

and the third is a default value which i, as administrator of the website, set. Could be 1 or could be 0.1

And i want to multiply those three parameters. So 4 times 3 times 1 equals 12 or 4 times 3 times 0,1 equals 0,12

Thats all
Its best that i ll try to do this myself. Thanks.

<div class="txtMult">
                    <div id="holder">
                    <input type="text" name="friends" id="inputbox" class="inputbox">
                    <input type="hidden" class="selected_ids" value="selected_ids" name="selected_ids[]" multiple="yes" id="selected_ids" /><br /><br />
                    </div>
                    <input type="number" name="txtEmmail" class="val1" /> times
                    <span class="multTotal">0.00</span>
                </div>
                <script type="text/javascript">
                 $(document).ready(function () {
                       $(".txtMult input").keyup(multInputs);
                       function multInputs() {
                           var mult = 0;
                           $("div.txtMult").each(function () {
                               var $val1 = $('.val1', this).val();
                               var $val2 = $('.selected_ids').length;
                               var $total = ($val1 * 1) * ($val2 * 1) * 0.1
                               $('.multTotal',this).text($total);
                               mult += $total;
                           });
                       }
                  });
                </script>

thats the solution to what i wanted to do

<div class="txtMult">
                    <div id="holder">
                    <input type="text" value="<?php echo $_POST['selected_ids']; ?>" name="friends" id="inputbox" class="inputbox">
                    <input type="hidden" class="selected_ids" value="selected_ids" name="selected_ids[]" multiple="yes" id="selected_ids" /><br /><br />
                    </div>
                    <input type="number" name="txtEmmail" class="val1" /> times
                    <span class="multTotal">0.00</span>
                </div>
                <script type="text/javascript">
                 $(document).ready(function () {
                       $(".txtMult input").keyup(multInputs);
                       function multInputs() {
                           var mult = 0;
                           // for each row:
                           $("div.txtMult").each(function () {
                                 var curval = $('#selected_ids').val();
                                var curval_arr = curval.split(',');
                                var $val2 = curval_arr.length;
                               // get the values from this row:
                               var $val1 = $('.val1', this).val();
                               var $val2 = curval_arr.length;
                               var $total = ($val1 * 1) * ($val2 * 1) * 0.1
                               $('.multTotal',this).text($total);
                               mult += $total;
                           });
                       }
                  });
                </script>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.