Jump to content

"if else" not working


stephenT

Recommended Posts

Can anyone please advise what i am missing in my code? I want the displayed price to show as $k when under $999,999 and $mil when over $1 million. Example: $990000 should display as $990k (which it does) BUT $1,100,000 should display as $1.1mil, and the same with values under $1mil should show as $k not $0.9mil. Hope that makes sense.

 

 

$(function() {

 

$( "#slider-range" ).slider({

range: true,

min: 0,

max: 2000000,

values: [ 0, 2000000 ],

step: 10000,

slide: function( event, ui )

{

 

if("HousePrice_max" < 1000000)

 

$( "#HousePrice" ).val( "$" + ui.values[ 0 ]/1000 + "k - $" + ui.values[ 1 ]/1000 + "k" );

 

else

 

$( "#HousePrice" ).val( "$" + ui.values[ 0 ]/1000 + "k - $" + ui.values[ 1 ]/1000000 + "mil" );

 

}

Link to comment
https://forums.phpfreaks.com/topic/261410-if-else-not-working/
Share on other sites

I haven't even read your post, mostly because I couldn't be bothered considering you couldn't be bothered popsting it within the correct board.

 

This however:

 

if("HousePrice_max" < 1000000)

 

makes little sense. How exactly do you expect the string "HousePrice_max" to be less than the int 1000000

 

Ever heard the expression "like comparing apples and oranges" ?

Link to comment
https://forums.phpfreaks.com/topic/261410-if-else-not-working/#findComment-1339528
Share on other sites

I'm new to php, this is my first post, it might be my last as i didn't expect this type of hostility on here. I was under the impression this forum was to help people with php.

 

The PHP Help board *is* for help with PHP questions. Unfortunately, your code is not PHP.

 

All i have done is move your question to the appropriate board and ask you a question.

Link to comment
https://forums.phpfreaks.com/topic/261410-if-else-not-working/#findComment-1339540
Share on other sites

That's correct.  I have it working however it is showing as $0.99mil when the slider goes below $1mil, i want it to display as $990k NOT $0.99mil. The same with the left slider, it displays as $990k for example but does not change to $mil when it goes over $1mil, instead displays as $1100k for example instead of $1.1mil

Link to comment
https://forums.phpfreaks.com/topic/261410-if-else-not-working/#findComment-1339549
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.