hi i am new in javascript i need it for job and my boss give me following task
write javascript program which ask you enter some name and display hello+name
i know it is trivial but i am tottaly new and am now in job please help
thanks
views:
66answers:
2
+3
A:
Hmmm, this is fairly fundamental. You'll do best to read up a bit more and try things yourself. That's the best way to learn.
For reference, though, the following should suffice (this once)
<input type="text" id="mytextbox" />
<input type="button" value="click me" onclick="clickbutton();" />
<script type="text/javascript">
function clickbutton(){
alert("Hello " + document.getElementById("mytextbox").value);
}
</script>
If you paste this into an empty HTML file, then run it, it should work.
There is tons missing from this, though!
James Wiseman
2010-08-17 12:07:37
+2
A:
I echo Pekka's statement, but for reference this is how you would do it:
<html>
<head>
<script type="text/javascript">
function onClickFunc() {
var input = document.getElementById("input");
alert("Hello " + input.text +"!");
}
</script>
</head>
<body>
<form>
<input type="text" id="input" />
<input type="submit" onclick="onClickFunc();" />
</form>
</body>
</html>
Stephen
2010-08-17 12:08:56