Author Topic: if statements with javascript  (Read 373 times)

0 Members and 1 Guest are viewing this topic.

Offline MDanzTopic starter

  • Devotee
    • View Profile
if statements with javascript
« on: February 09, 2010, 06:08:59 AM »
is it possible to do...

if (javascript function)

??

Offline MasterACE14

  • Addict
  • Gender: Male
  • Reverse your World.
    • View Profile
    • Crikey Games Pty Ltd
Re: if statements with javascript
« Reply #1 on: February 09, 2010, 06:13:47 AM »
yes
Crikey Games Pty Ltd | Realm Battles | Conflicting Forces in development...

It's too big a world to be in competition with everyone.  The only person who I have to be better than is myself. ~Harry Morgan

Offline MDanzTopic starter

  • Devotee
    • View Profile
Re: if statements with javascript
« Reply #2 on: February 09, 2010, 06:19:10 AM »
how do i do it?

i have a javascript function called ChgTxt..

if(ChgTxt) {}   lol

Offline MrAdam

  • Addict
  • Gender: Male
    • View Profile
Re: if statements with javascript
« Reply #3 on: February 09, 2010, 07:01:44 AM »
Use the 'typeof' operator to check it's defined as a function:

Code: [Select]
if (typeof ChgTxt == 'function') {
Ronnie Wood, true or false?

Offline yozyk

  • Irregular
  • Gender: Male
    • View Profile
Re: if statements with javascript
« Reply #4 on: February 09, 2010, 10:32:13 AM »
It is necessary that the function returns the value.
Use return operator in function body.
I am learning PHP and English simultaneously

Offline MrAdam

  • Addict
  • Gender: Male
    • View Profile
Re: if statements with javascript
« Reply #5 on: February 09, 2010, 10:42:18 AM »
It is necessary that the function returns the value.
Use return operator in function body.


... What?
Ronnie Wood, true or false?

Offline yozyk

  • Irregular
  • Gender: Male
    • View Profile
Re: if statements with javascript
« Reply #6 on: February 09, 2010, 10:49:02 AM »
Code: (javascript) [Select]
function ChgTxt() {
  // your code
  return boolValue;
}

if(ChgTxt) alert('True!')
else alert('False!')
I am learning PHP and English simultaneously

Offline MrAdam

  • Addict
  • Gender: Male
    • View Profile
Re: if statements with javascript
« Reply #7 on: February 09, 2010, 10:58:33 AM »
From the OP I got the impression he wanted to check if the function exists, you may be right.
Ronnie Wood, true or false?

PHP Freaks Forums

« on: »

Tired of these ads? Purchase a supporter subscription to get rid of them.