1

How do I exactly put a php value in a js line? I tried:

$("#slider").editRangeSlider({range:{min: "<?= $field[ 'range_min' ] ?>" , max: "<?= $field[ 'range_max' ] ?>" }});

First I had it the other way around, I echoed the javascript line in php and put the fields with:

' . $field[ 'range_min' ] . '

That worked fine but I think php in js would be a cleaner way to do this. How to do this? Thanks.

1
  • 5
    You have to echo right? Commented Jul 5, 2013 at 8:28

5 Answers 5

2

To print variable in PHP you shoud do:

<?php echo $field[ 'range_min' ]; ?>

or

<?=$field[ 'range_min' ]; ?>
Sign up to request clarification or add additional context in comments.

Comments

2
$("#slider").editRangeSlider({range:{min: "<?php echo $field[ 'range_min' ]; ?>" , max: "<?php echo $field[ 'range_max' ]; ?>" }});

you need to echo it.

Comments

0

you need to use echo.

$("#slider").editRangeSlider({range:{min: "<?php echo $field[ 'range_min' ] ?>" , max: "<?php echo $field[ 'range_max' ] ?>" }});

Comments

0

You're missing semicolons and you need to echo:

$("#slider").editRangeSlider({range:{min: "<?php echo $field[ 'range_min' ]; ?>" , max: "<?php echo $field[ 'range_max' ]; ?>" }});

Comments

0

DO that:

$("#slider").editRangeSlider({range:{min: "<?php echo $field[ 'range_min' ]; ?>" , max: "<?php echo $field[ 'range_max' ]; ?>" }});

You have forgot to echoing it.

Comments

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.