Take the 2-minute tour ×

I'm trying to put "mobiscroll" (a select list) values into a textbox, but three times in one page, the strange thing is that if I choose to view it only one time it's working... Also, how do I make it display the first number even if hasn't been selected by the user? I tried with "selected" after "value" but it isn't working..


Another question, what should I do if I want to multiply only one the result by 2? I'm trying to do it with this example but it isn't working..

share|improve this question
Do you debug with chrome, or firebug? It gives me an error on line 47 as soon as i hit the counter, not just after 3 times. I see first your [cycle] getting terminated, cause there are to few slides, and most likely your javascript is borking on that. On your second awnser, it is indeed selected as you say, but if your slider isn't working, it has no use to enter it, cause it wont find a value to put there. –  Dorvalla Oct 12 '12 at 13:40
ok, I fixed the error (I think), but it's still not working, what should I do/change? The numbers are supposed to be seen on those three empty spaces.. –  Winegood Vino Oct 12 '12 at 13:53

1 Answer 1

up vote 1 down vote accepted
var f = document.frm;
f.sel_value.value = sel.options[sel.selectedIndex].value;

doesn't work for two reasons:

  1. The <input name="sel_value"> elements are not within the form. You have an opening <form> tag, but no close tag, but the form is implicitly closed by the </div> that closes the <div> that contains it.

  2. The assignment will only fill in one input, it doesn't automatically loop over all of them like jQuery does.



To make it fill in these fields when the page loads, you need:

        preset: 'select',
        theme: 'default',
        display: 'inline',
        mode: 'clickpick',
        inputClass: 'i-txt'

To multiply the value before filling in some of the inputs, change those inputs to:

<input type="text" name="sel_value" data-multiply="2" .../>

Change aggiornaHidden to:

function aggiornaHidden(sel){
  $("input[name=sel_value]").each(function() {
      var multiply = $(this).data("multiply") || 1;
      $(this).val($(sel).val() * multiply);
share|improve this answer
ok, that worked, there's only one thing left, how do I make it display the first number? (option "selected" I mean, but it isn' working) –  Winegood Vino Oct 12 '12 at 14:31
Call aggiornaHidden($("#select")) in your main jQuery function, so it will display the selected value when the page is loaded. Currently you're only doing it in the onchange handler. –  Barmar Oct 12 '12 at 14:47
ehm, where exactly do I have to write it? thanks –  Winegood Vino Oct 12 '12 at 15:06
Inside $(function...). That's where you put everything you want to run when the page loads, right? See my edited answer. –  Barmar Oct 12 '12 at 15:15
thank you so much! –  Winegood Vino Oct 12 '12 at 15:30

Your Answer


