Javascript Paypal slider string suffix
Ad
I have this code http://jsfiddle.net/y8owze31/6/. I need to be able to apply a suffix to the string via a variable. The way I am doing it now is very primitive. What I mean is
$(function() {
var1 = "suffix"
$( "#slider-range-max" ).slider({
range: "max",
min: 1,
max: 50,
value: 25,
slide: function( event,ui, string) {
$( "#amount" ).val( ui.value + "suffix" );
$( "#amt_id" ).val( ui.value );
}
});
$( "#amount" ).val( $( "#slider-range-max" ).slider( "value" ) );
});
But this doesn't seem to work the way I would like it to and just tries to calculate with the string.
Ad
Answer
Ad
In you situation, you need to define your value type in:
$( "#amount" ).val( ui.value + "suffix" );
and in:
$( "#amount" ).val( $( "#slider-range-max" ).slider( "value" ) );
javascript does not know which type of data you enter. You should define such as respectively:
$( "#amount" ).val( "" + ui.value + "suffix" );
and
$( "#amount" ).val("" + $( "#slider-range-max" ).slider( "value" ) + "suffix" );
See, you add some quotation mark in where your value is you simply edit your variable as a string value.
Cheers!
And here is JSFiddle example
Ad
source: stackoverflow.com
Related Questions
Ad
- → How to update data attribute on Ajax complete
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → Octobercms Component Unique id (Twig & Javascript)
- → Passing a JS var from AJAX response to Twig
- → Laravel {!! Form::open() !!} doesn't work within AngularJS
- → DropzoneJS & Laravel - Output form validation errors
- → Import statement and Babel
- → Uncaught TypeError: Cannot read property '__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED' of undefined
- → React-router: Passing props to children
- → ListView.DataSource looping data for React Native
- → Can't test submit handler in React component
- → React + Flux - How to avoid global variable
- → Webpack, React & Babel, not rendering DOM
Ad