5 Replies - 751 Views - Last Post: 22 January 2009 - 09:07 AM

#1 rmw  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 33
  • Joined: 29-November 08

Yes/No Function ?

Post icon  Posted 21 January 2009 - 05:52 AM

Hi,

Looking at other forums etc, there seems to be conflicting answers on whether there is an yes/no function in javascript?

Does anyone know the true answer? and if not has anyone written one that I could steal :)

Thanks

This post has been edited by rmw: 21 January 2009 - 05:54 AM

Is This A Good Question/Topic? 0
  • +

Replies To: Yes/No Function ?

#2 jjsaw5  Icon User is offline

  • I must break you
  • member icon

Reputation: 90
  • View blog
  • Posts: 3,060
  • Joined: 04-January 08

Re: Yes/No Function ?

Posted 21 January 2009 - 05:53 AM

View Postrmw, on 21 Jan, 2009 - 07:52 AM, said:

Does anyone know the true answer? and if not has anyone written one that I could steal :)

Thanks



No one here is going to give you source code. Try writing it on your own and then you can post back here when you are stuck or get error messages.
Was This Post Helpful? 0
  • +
  • -

#3 rmw  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 33
  • Joined: 29-November 08

Re: Yes/No Function ?

Posted 21 January 2009 - 05:58 AM

View Postjjsaw5, on 21 Jan, 2009 - 04:53 AM, said:

View Postrmw, on 21 Jan, 2009 - 07:52 AM, said:

Does anyone know the true answer? and if not has anyone written one that I could steal :)

Thanks



No one here is going to give you source code. Try writing it on your own and then you can post back here when you are stuck or get error messages.


Fair comment - So I take from this there is no a function and it has to be written?
Was This Post Helpful? 0
  • +
  • -

#4 Christopher Elison  Icon User is offline

  • D.I.C Head

Reputation: 39
  • View blog
  • Posts: 230
  • Joined: 29-December 08

Re: Yes/No Function ?

Posted 21 January 2009 - 06:18 AM

You could use the confirm function, although I'm not sure if you can change it to prompt as Yes/no.

<script type="text/javascript">
if (confirm("Do you like hamburgers?")) {
  document.writeln("It seems you like eating hamburgers - yummy!\n");
} else {
  document.writeln("You don't like hamburgers!\n");
}
</script>


Was This Post Helpful? 0
  • +
  • -

#5 xerxes333  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 31
  • View blog
  • Posts: 504
  • Joined: 05-July 07

Re: Yes/No Function ?

Posted 22 January 2009 - 07:19 AM

What do you mean yes/no function? There is the built in confirm prompt that ChrisE has pointed out. But if you want a modal window that prompts the user with yes and no buttons then you will have to write one from scratch.
Was This Post Helpful? 0
  • +
  • -

#6 teampoop  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 17
  • View blog
  • Posts: 140
  • Joined: 19-June 08

Re: Yes/No Function ?

Posted 22 January 2009 - 09:07 AM

(question)?"Yes":"No";


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1