user3111350
user3111350

Reputation: 49

Change text on div, if change value of input JS

This my code:

 <script>
  $(function() {
    $( "#slider-vertical" ).slider({
      orientation: "vertical",
      range: "min",
      min: 0,
      max: 100000,
      step: 5000,
      value: 5000,
      slide: function( event, ui ) {
        $( "#amount" ).val( ui.value );
      }
    });
    $( "#amount" ).val( $( "#slider-vertical" ).slider( "value" ) );
  });
    </script>

HTML

<p>
  <label for="amount">Стоимость:</label>
  <input name="amount" type="text" id="amount" style="border:0; color:#f6931f; font-weight:bold;" size="4">Р
</p>

This is trackbar. I want to change text on div, when change value of input. Pls, help with js code.

Upvotes: 0

Views: 199

Answers (2)

Schien
Schien

Reputation: 3903

Give the div an ID, say, "result",

Then in under $("#amount").val(ui.value);, add:

document.getElementById('result').innerHTML=ui.value;

(Edited)

Upvotes: 1

Petr Volny
Petr Volny

Reputation: 569

In your example I do not see a <div id="slider-vertical"></div> for the vertical slider in your HTML. Otherwise, your code seems ok and worked for me in this jsbin: http://jsbin.com/aCedAVi/1/edit

Upvotes: 0

Related Questions