简体   繁体   中英

Use a form field input to set an anythingSlider value

I can't seem to figure out how to make a form input box such that when you click a submit button, the value of that input box is updating this slider

http://css-tricks.com/anythingslider-jquery-plugin/

$('#myForm').click ( function() { $('#slider').anythingSlider(formVal); } )

After reading your comment and fixing your question, I think you mean

<script>
$(document).ready(function() {
  $('#myButton').click(function() { 
    $('#slider').anythingSlider($("#myField").val()); 
  })
});
</script>
<form>
<input type="text" id="myField" value="" />
<input type="button" id="myButton"/>
</form>

Create an input box and a button in html body

<form>
  <input id='input1' name='input1' />
  <input type='button' value='Submit' id='submit' onclick='onSubmit()' />
</form>

Add this function to your javascript

function onSubmit() {
  formVal = document.getElementbyId('input1').value
}

For your case, use JQuery as

$document.ready(function() {
  $('#submit').click(function() {
    var formval = $('$inpupt1').val();
    $('#slider').anythingSlider(formVal); 
  });
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM