0

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.

2
  • Please reformat your code Commented Jan 19, 2014 at 20:51
  • I don't understand, which div? Commented Jan 19, 2014 at 20:53

2 Answers 2

1

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

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

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

(Edited)

Sign up to request clarification or add additional context in comments.

2 Comments

Any reason why the down vote? Help me improve my answer next time. Thanks.
Well, then use document.getElementById('result').innerHTML=ui.value. Why do people stick to jQuery syntax for even the most trivial tasks? And thank you BlackSheep for pointing this out.
0

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

2 Comments

code is right - yes. I want see next: if value 5000 - then <div id=bla>hello</div> if value 10000 - then <div id=bla>HELLO TWO!!</div> ...
I am afraid I don't understand the question properly. Can you please add the <div> you want to change in the HTML section of your question and elaborate on what and would you like to see in that div and when.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.