Go Back   Computer Forums > General Computing > Programming
Click Here to Login
Join Computer forums Today


Reply
 
Thread Tools Search this Thread Display Modes
 
Old 03-17-2014, 04:47 AM   #1
Beta Member
 
Join Date: Mar 2014
Location: France
Posts: 2
Default Javascript Help

<!DOCTYPE html>
<html>
<body>



Age:<input id="age" value="18" />

<button onclick="myFunction()">Try it</button>

<p id="demo"></p>

<script>
function myFunction()
{
var voteable;
var age;
age=document.getElementById("age").value; what does .value mean?
voteable=(age<18)?"Too young":"Old enough"; Why are you using the age variabel here?
document.getElementById("demo").innerHTML=voteable ;
}
</script>

</body>
</html>
__________________

spacehead is offline   Reply With Quote
Old 03-17-2014, 12:06 PM   #2
Fully Optimized
 
jmacavali's Avatar
 
Join Date: Jun 2009
Posts: 4,867
Default Re: Javascript Help

While I have no programing experience, it would probably be helpful if you would ask a question or explain the situation instead of just posting code.
__________________

__________________
****************************************
Don't take life too seriously -- no one gets out alive. Plus, who wants to arrive to the hereafter in pristine condition wearing a suit and tie?
I want to slide in sideways, worn out, used up, hair a mess, clothes tattered, & screaming, "Whooo! What a ride!"
****************************************
jmacavali is offline   Reply With Quote
Old 03-17-2014, 12:30 PM   #3
Fully Optimized
 
ssc456's Avatar
 
Join Date: Jan 2007
Posts: 4,279
Send a message via MSN to ssc456
Default Re: Javascript Help

Quote:
Originally Posted by spacehead View Post
<!DOCTYPE html>
<html>
<body>



Age:<input id="age" value="18" />

<button onclick="myFunction()">Try it</button>

<p id="demo"></p>

<script>
function myFunction()
{
var voteable;
var age;
age=document.getElementById("age").value; what does .value mean?
voteable=(age<18)?"Too young":"Old enough"; Why are you using the age variabel here?
document.getElementById("demo").innerHTML=voteable ;
}
</script>

</body>
</html>
Yes this isn't very helpful.
Unless your question is those bits in bold but still not very helpful.

The answers are: .value simply gets the value of the element you are looking for.
Why use the age variable? Well technically you don't have to you could just say:
voteable=(document.getElementById("age").value<18) ?"Too young":"Old enough";

But sometimes for readability of code it's a good idea to use variables.
__________________
He who has never failed has never attempted anything worth succeeding at.

Dont Eat Animals, Its Not Good For Them And They Dont Like It!
ssc456 is offline   Reply With Quote
Old 03-17-2014, 12:49 PM   #4
Fully Optimized
 
strollin's Avatar
 
Join Date: Mar 2011
Location: USA
Posts: 1,944
Default Re: Javascript Help

My guess is that spacehead just got ssc456 to do his/her homework.
strollin is offline   Reply With Quote
Old 03-17-2014, 01:17 PM   #5
Fully Optimized
 
jmacavali's Avatar
 
Join Date: Jun 2009
Posts: 4,867
Default Re: Javascript Help

Quote:
Originally Posted by strollin View Post
My guess is that spacehead just got ssc456 to do his/her homework.
This
__________________
****************************************
Don't take life too seriously -- no one gets out alive. Plus, who wants to arrive to the hereafter in pristine condition wearing a suit and tie?
I want to slide in sideways, worn out, used up, hair a mess, clothes tattered, & screaming, "Whooo! What a ride!"
****************************************
jmacavali is offline   Reply With Quote
Old 03-17-2014, 08:41 PM   #6
Golden Master
 
BK_123's Avatar
 
Join Date: Dec 2009
Location: Australia
Posts: 7,534
Default Re: Javascript Help

I don't mean to be a spammer but like others have said are you just asking for members to do this for you or are you posting it for no real reason just wasting time and being a spammer..
__________________

BK_123 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT -5. The time now is 06:51 PM.


Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0