The forum of the forums
Welcome to the Official Support Forum of Forumotion!

To take full advantage of everything offered by our forum, please log in if you are already a member, or join our community if you've not yet.



Create a free forum like this one.

JavaScript Alert Button Not Working

View previous topic View next topic Go down

Solved JavaScript Alert Button Not Working

Post by hoodedwarbler12 on July 1st 2011, 2:39 am

Hey guys, I'm having issues with the JavaScript alert box. I have put the following code in my head tags using templates:
Code:
<script type="text/javascript">
function wackybutton()
{
var r=confirm("Congratulations!  You found Wacky!  Click on OK.");
if (r==true)
  {
  alert("You clicked Wacky!  Contact hoodedwarbler12 and be sure to mention this phrase: WWN IS #1!");
  }
else
  {
  alert("I'm sorry, you Cancelled your prize.  Please click Wacky again.");
  }
}
</script>

And the following code in the script for the button:

Code:
<button type="button" onclick="wackybutton()"><img alt="wacky" src="http://r11.imgfast.net/users/1113/14/38/92/avatars/1-30.png"></button>

It doesn't work. Am I doing something wrong? It works on other sites but not my forumotion site.


Last edited by hoodedwarbler12 on July 1st 2011, 10:24 pm; edited 1 time in total

hoodedwarbler12
Forumember

Male Posts : 521
Reputation : 117
Language : English, Latin, HTML, JavaScript
Location : Tennessee, USA

http://www.webkinznation.com

Back to top Go down

Solved Re: JavaScript Alert Button Not Working

Post by SLGray on July 1st 2011, 3:03 am

Could it be this: (r==true)?

Does it suppose to be (r=true)?


When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.


SLGray
Administrator
Administrator

Male Posts : 36748
Reputation : 2449
Language : English
Location : United States

http://ztwds.forumotion.com/

Back to top Go down

Solved Re: JavaScript Alert Button Not Working

Post by LGforum on July 1st 2011, 3:18 am

Wouldn't button type be 'submit' ?

LGforum
Hyperactive

Male Posts : 2260
Reputation : 258
Language : English
Location : UK

http://www.avacweb.com/

Back to top Go down

Solved Re: JavaScript Alert Button Not Working

Post by hoodedwarbler12 on July 1st 2011, 1:42 pm

slg wrote:Could it be this: (r==true)?

Does it suppose to be (r=true)?
== means that it is exactly equal. I like using it just to make sure nothing unwanted happens.
@LGforum wrote:Wouldn't button type be 'submit' ?
I guess it could, let me go try that.
Submit button doesn't work either.

hoodedwarbler12
Forumember

Male Posts : 521
Reputation : 117
Language : English, Latin, HTML, JavaScript
Location : Tennessee, USA

http://www.webkinznation.com

Back to top Go down

Solved Re: JavaScript Alert Button Not Working

Post by Saxaca on July 1st 2011, 5:08 pm

This should work:
Code:
<script type="text/javascript">
function wackybox() {
   var x = confirm('foo');

   if (x == true) {
      alert('Go claim your prize with this code: WWN IS #1!');
   }

   else {
      alert('Uh, you did not press yes!');
   }
}
</script>

<a href="#" onclick="wackybox(); return false;"><img alt="wacky" src="http://r11.imgfast.net/users/1113/14/38/92/avatars/1-30.png"></a>

Saxaca
Forumember

Male Posts : 539
Reputation : 26
Language : Markup.

Back to top Go down

Solved Re: JavaScript Alert Button Not Working

Post by hoodedwarbler12 on July 1st 2011, 7:25 pm

@Saxaca wrote:This should work:
Code:
<script type="text/javascript">
function wackybox() {
   var x = confirm('foo');

   if (x == true) {
      alert('Go claim your prize with this code: WWN IS #1!');
   }

   else {
      alert('Uh, you did not press yes!');
   }
}
</script>

<a href="#" onclick="wackybox(); return false;"><img alt="wacky" src="http://r11.imgfast.net/users/1113/14/38/92/avatars/1-30.png"></a>

Hmm, is that made to go in a post? It's not working when I put the top part in the head tags and the bottom in a post. And it doesn't work when I put the whole thing in a post either. Thanks for responding though!

EDIT: Fixed, I made an html page and then an iFrame to it.

hoodedwarbler12
Forumember

Male Posts : 521
Reputation : 117
Language : English, Latin, HTML, JavaScript
Location : Tennessee, USA

http://www.webkinznation.com

Back to top Go down

Solved Re: JavaScript Alert Button Not Working

Post by Nera. on July 1st 2011, 10:30 pm

Solved ~ Locked

Nera.
Energetic

Female Posts : 7077
Reputation : 2013
Language : English
Location : -

http://webartzforum.com

Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum