Click to See Complete Forum and Search --> : Specify a value, but only if it does contain one....


jshowe
06-30-2003, 05:29 PM
Hi all!

I am in need of a little help. I have this variable. Lets say "newprice".

I would like newprice = 0 but only if newprice doesn't contain any other value(0-100000000000000 - ANYTHING).

Any ideas? Thanks.

Charles
06-30-2003, 05:33 PM
if (!newprice) newprice = 0

jshowe
06-30-2003, 05:46 PM
For some reason that doesn't seem to be doing it. Will it still return false if newprice doesn't exist?

Charles
06-30-2003, 05:59 PM
<script type="text/javascript">
<!--
var newprice;
if(!newprice) newprice = 'foo'
alert(newprice)
// -->
</script>

or

<script type="text/javascript">
<!--
if (!window.newprice) window.newprice = 'foo'
alert(window.newprice)
// -->
</script>

jshowe
06-30-2003, 05:59 PM
Thank you both! That did the trick.