Reputation: 1
I'm trying to create a simple calculator for a project I'm working on. JQuery and JavaScript isn't really familiar to me. My code should allow the user to enter an amount, if the amount in the input box then equals a certain amount, the header I have will be changed to the appropriate value.
$("#btn-equity").click(function() {
if ( 50 < $('#Equity').val() < 99 ) {
$('#rev1').text("500");
}
});
Nothing happens upon clicking the button and I'm unsure as to what the issue is. If anybody could assist, that'd be amazing!
HTML
<div class="input-prepend input-append">
<span class="add-on">$</span>
<input class="span2" id="Equity" type="text">
<span class="add-on">.00</span>
</div>
<input type="button" class="btn btn-large btn-success btn-equity" id="btn-equity" value="Determine Equity">
</center>
<center>
<h1 id="rev1">NA</h1>
Upvotes: 0
Views: 51
Reputation: 11749
You should do like this...
$("#btn-equity").click(function() {
var equity = $('#Equity').val()
if (( 50 < equity )&&( equity < 99 )) {
$('#rev1').html("500");}
});
Upvotes: 1
Reputation: 4656
it is working to me : http://jsfiddle.net/3AV7B/
$("#btn-equity").click(function() {
if ( $('#Equity').val() > 50 && $('#Equity').val() < 99 ) {
$('#rev1').text("500");
}
});
Upvotes: 0
Reputation: 32598
You can't chain comparator operators like that - you need two separate statements:
var value = $('#Equity').val();
if ( 50 < value && value < 99 ) {
Upvotes: 0