CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   JavaScript programming (http://www.codingforums.com/forumdisplay.php?f=2)
-   -   buttan onClick (http://www.codingforums.com/showthread.php?t=285098)

swenn 01-01-2013 12:02 PM

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:

http://i45.tinypic.com/1411pp4.jpg
http://i46.tinypic.com/6j0ro3.jpg

xelawho 01-01-2013 03:35 PM

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>


Dormilich 01-02-2013 09:47 AM

Quote:

Originally Posted by swenn (Post 1303371)
Code:

function menu-dropdown() {

"SyntaxError: missing ( before formal parameters"

in other words, - is not a valid character for a variable/function name.


All times are GMT +1. The time now is 03:25 PM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.