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.

Elias Van Ootegem
76.7k10 gold badges123 silver badges160 bronze badges
asked Jul 5, 2013 at 8:27
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' ]; ?>
answered Jul 5, 2013 at 8:29
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.

answered Jul 5, 2013 at 8:29

Comments

0

you need to use echo.

$("#slider").editRangeSlider({range:{min: "<?php echo $field[ 'range_min' ] ?>" , max: "<?php echo $field[ 'range_max' ] ?>" }});
answered Jul 5, 2013 at 8:29

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' ]; ?>" }});
answered Jul 5, 2013 at 8:29

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.

hsz
153k63 gold badges269 silver badges320 bronze badges
answered Jul 5, 2013 at 8:30

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.