Jump to content

php & js range


sopranolv

Recommended Posts

this working to select range and import in db and problem is that the don't show in slider range from mysql db

 

 

 need this

 

<?=$user['sage']?> and <?=$user['sageto']?>

 

to show here

 

values: [ 2, 4 ],

 

js

  $(function() {
    $( "#slider-range" ).slider({
      range: true,
      min: 1,
      max: 100,
      values: [ 2, 4 ],
      slide: function( event, ui ) {
        $( "#amount" ).val( "$" + ui.values[ 0 ] + " - $" + ui.values[ 1 ] );
        $( "input#bed_min").val(ui.values[ 0 ]);
        $( "input#bed_max").val(ui.values[ 1 ]);
      }
    });
    $( "#amount" ).val( "$" + $( "#slider-range" ).slider( "values", 0 ) +
      " - $" + $( "#slider-range" ).slider( "values", 1 ) );
  });

php

<p>
  <label for="amount">Price range:</label>
  <input type="text" id="amount" style="border: 0; color: #f6931f; font-weight: bold;" />
</p>
 
<div style="width:400px;" id="slider-range"></div>


      min: <input id="bed_min" type="text" value="<?=$user['sage']?>" name="sage"><br>
      max: <input id="bed_max" type="text" value="<?=$user['sageto']?>" name="sageto">


Edited by sopranolv
Link to comment
Share on other sites

If the javascript is in the same file as your php code then replace the 2 and the 4 with your PHP variables

values: [ <?=intval($user['sage'])?>, <?=intval($user['sageto'])?> ],

Otherwise get the values from the two text fields

values: [ parseInt($( "input#bed_min").val()), parseInt($( "input#bed_max").val()) ],
  • Like 1
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.