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
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
Share on other sites

It is, but you posted a javascript question (I'm assuming in the PHP area).

 

Anyways, to elaborate on the last poster's comment:

 

if("HousePrice_max" < 1000000)

You are comparing a string (text) of "HousePrice_max" to a number. What are you trying to compare to?

Link to comment
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
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
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.