School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 300,485 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,780 people online right now. Registration is fast and FREE... Join Now!




lolwut1 (alert boxes)

 

lolwut1 (alert boxes), alerts and script blocks

p3lvi5

25 Jun, 2009 - 06:58 AM
Post #1

New D.I.C Head
*

Joined: 21 Oct, 2007
Posts: 4


My Contributions
Alright, first off, sorry about the asinine question but I'm really new at this. I make an alert box that's supposed to come up under a certain condition, but the same one seems to pop up regardless of what I change the conditional value to, I know this question is probably beneath you guys...Also, pardon my somewhat...informal approach to writing practice script...

CODE
<html>
<head>
<title>Variable Test</title>
<script type="text/javascript">
balls=2;
wiener=1;
genitals=balls+wiener;
document.write(genitals);
if (genitals=3)
{
alert(" "+"Hey! Your Balls Are Showing!")
}
else
{
alert(" "+"Go on, Git!!!")
}

</script>
</head>
<body>
</body>
</html>


Everything appears to be written correctly, but if it was I couldn't change the value of wiener or balls and still get an alert message that tells me that said balls are showing. Thanks for your help/patience!





User is offlineProfile CardPM
+Quote Post


RudiVisser

RE: Lolwut1 (alert Boxes)

25 Jun, 2009 - 07:02 AM
Post #2

.. does not guess solutions
Group Icon

Joined: 5 Jun, 2009
Posts: 1,872



Thanked: 137 times
Dream Kudos: 125
Expert In: PHP, MySQL, HTML, CSS, C#

My Contributions
To compare values, you need to use ==, not just =, you're actually just setting the value of genitals to 3 in your if statement. Since you can always change variables, the outcome of that is always going to be true smile.gif
User is offlineProfile CardPM
+Quote Post

p3lvi5

RE: Lolwut1 (alert Boxes)

25 Jun, 2009 - 07:08 AM
Post #3

New D.I.C Head
*

Joined: 21 Oct, 2007
Posts: 4


My Contributions
QUOTE(MageUK @ 25 Jun, 2009 - 07:02 AM) *

To compare values, you need to use ==, not just =, you're actually just setting the value of genitals to 3 in your if statement. Since you can always change variables, the outcome of that is always going to be true smile.gif


You're a saint! A SAINT!!

Thanks, man!
User is offlineProfile CardPM
+Quote Post

Xioshin

RE: Lolwut1 (alert Boxes)

2 Jul, 2009 - 04:45 PM
Post #4

D.I.C Head
**

Joined: 5 Nov, 2008
Posts: 213

This should be featured.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/8/09 04:08AM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month