Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-01-2013, 12:02 PM   PM User | #1
swenn
New to the CF scene

 
Join Date: Jan 2013
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
swenn is an unknown quantity at this point
buttan onClick

Hey there!

I've just started with all this website building stuff and now I'm stuck.

I'm struggling with a function that I cannot get to work. The thing is actually pretty simple, but I am out of ideas and so is Google.

What I want to do is: when the 'Login' button is clicked, there should appear an extension under the button, where users can fill in their log-in information.

Since I am a total beginner, I tried to work it out from a bit of code from W3Schools' website. Unfortunately, it didn't work, but anyway: here is what I have got at the moment.

Code:
<script type="text/javascript"> 
	function menu-dropdown() {
		document.getElementById("ddlogin").innerHTML="login";
	}
</script>
The code above was just a check, if it outputs anything, but nothing was shown.

I also tried to insert <form> right into "innerHTML="here";".

I'm sorry for being a total newbie, but I feel like I can't continue if this thing remains a mistery for me. So, please don't judge me too hard.

I will provide some pictures:


swenn is offline   Reply With Quote
Old 01-01-2013, 03:35 PM   PM User | #2
xelawho
Senior Coder

 
xelawho's Avatar
 
Join Date: Nov 2010
Posts: 2,437
Thanks: 52
Thanked 453 Times in 451 Posts
xelawho will become famous soon enoughxelawho will become famous soon enough
if it's an entire form you are better off hiding it on page load and showing it when the button is pressed:

Code:
<!doctype html>
<html>
<head>
<style>
#myform{
display:none;
}
</style>
</head>
<body>
<input type="button" value="show form" onclick="showIt()"/>
<form id="myform">
<input/><br>
<input/>
</form>
<script>
function showIt(){
document.getElementById("myform").style.display="block";
}
</script>
</body>
</html>
xelawho is offline   Reply With Quote
Old 01-02-2013, 09:47 AM   PM User | #3
Dormilich
Senior Coder

 
Dormilich's Avatar
 
Join Date: Jan 2010
Location: Behind the Wall
Posts: 2,863
Thanks: 9
Thanked 291 Times in 287 Posts
Dormilich is on a distinguished road
Quote:
Originally Posted by swenn View Post
Code:
function menu-dropdown() {
"SyntaxError: missing ( before formal parameters"

in other words, - is not a valid character for a variable/function name.
__________________
please post your code wrapped in [CODE] [/CODE] tags
Dormilich is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

Forum Jump


All times are GMT +1. The time now is 06:50 AM.


Advertisement
Log in to turn off these ads.