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

Go down

Solved JavaScript Alert Button Not Working

Post by hoodedwarbler12 on Fri Jul 01, 2011 8: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 Sat Jul 02, 2011 4:24 am; edited 1 time in total
avatar
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 Fri Jul 01, 2011 9: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.

avatar
SLGray
Administrator
Administrator

Male Posts : 42704
Reputation : 3006
Language : English
Location : United States

https://fmthemes.forumotion.com/

Back to top Go down

Solved Re: JavaScript Alert Button Not Working

Post by LGforum on Fri Jul 01, 2011 9:18 am

Wouldn't button type be 'submit' ?
avatar
LGforum
Hyperactive

Male Posts : 2263
Reputation : 260
Language : English
Location : UK

http://www.avacweb.com/

Back to top Go down

Solved Re: JavaScript Alert Button Not Working

Post by hoodedwarbler12 on Fri Jul 01, 2011 7: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.
avatar
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 Fri Jul 01, 2011 11: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>
avatar
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 Sat Jul 02, 2011 1:25 am

@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.
avatar
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 Sat Jul 02, 2011 4:30 am

Solved ~ Locked
avatar
Nera.
Energetic

Female Posts : 7078
Reputation : 2014
Language : English
Location : -

http://webartzforum.com

Back to top Go down

Back to top


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