Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
I am new to html. I am trying to get time but the code is not working in browser. please help
<h1>My First JavaScript</h1>
<button type="button"
onclick="document.getElementByid('time').innerHTML = Date()">
Click me to display Date and Time.</button>
<p id="time"></p>
</body>
</html>
Typo in your code,
document.getElementByid('time')
should be:
document.getElementById('time')
(you miss the i capital)
For simple debugging like this, you can use the console of your web browser. Just hit F12, and look into the console, the error will be described here.
There is a typo here:
document.getElementByid
should be
document.getElementById
Working example here.
Please fix that line :
document.getElementByid('time')
and change it to
document.getElementById('time')
<button type="button"
onclick="document.getElementById('time').innerHTML = Date()">
Click me to display Date and Time.</button>
<p id="time"></p>
You spelt getElementById wrong
Please Change Next line:
document.getElementByid('time')
to:
document.getElementById('time')
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
http://jsfiddle.net/t32h0gj4/4/
how to show variable inside input box<b id="smsCount"></b> SMS (<b id="smsLength"></b>) Characters left
<br />
<input type= "text" id= "smsCount" ></input>
<textarea id="smsText" style="width:400px;height:200px"></textarea>
Please help me
Fixed: http://jsfiddle.net/t32h0gj4/5/
Changes:
HTML: change id="smsCount" to class="smsCount" (id's need to be unique)
JavaScript: change the selector to .smsCount and further below also call the jQuery .val() function to set the input box.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
here is what i'm doing but it doesn't work. I have to change the texte in the textarea but I don't know how to get it? thanks
<%
/** Variables */
String valeurTexte;
/** Logique */
valeurTexte = request.getParameter("texte");
valeurTexte=valeurTexte.replaceAll("Ç","Ç");
out.println("Votre texte: "+ valeurTexte);
%>
<form>
<textarea name="texte">ici</textarea>
<input type='submit'>
</form>
</body>
</html>
It's hard to see exactly what you want from the question, but assuming this is javascript because of the tag, give the textarea an id and do document.getElementById("myId").innerText=sometext
or document.getElementsByName("texte") and find the textarea
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I'm learning to link js with html so I wrote this but it didn't work
I need to know what's the problem with it!!
Code :
<Html>
<head>
<title>test</title>
<Script>
Function test() {
Alert(document.getElementById("input").value);
}
</script>
</head>
<Body>
<form>
<fieldset>
<input Type="text" name="input" id="input" />
<Button onClick="test()"> alert</button>
</fieldset>
</form>
</Body>
</Html>
Check your console. There's no function called Alert(). It's case sensitive. You're looking for alert(); and it should be function with a lowercase "F".
Also, inline JavaScript (such as onclick in your html) is bad practice. Study up on that here: https://www.google.com/search?q=Why+is+inline+js+bad%3F
By the way, html isn't case-sensitive, but it's standard practice to use lowercase. I think it's relevant to mention here since you're having case-sensitive issues with JavaScript.
This is a very low quality question. You haven't told us what you expect this code to do (alert the contents of the text box, I assume). In the future, please do not use "it doesn't work" as a description of a problem. I'll cut you some slack since it looks like you're new, though.
Anyways, if you had opened up the JavaScript console in the browser, you would have seen a syntax error (or "Unexpected Identifier") on Line 5. That's where you declare your test() function. Let's have a look at it:
Function test() {
Alert(document.getElementById("input").value);
}
Notice you're using "Function". JavaScript is case sensitive, which means that function and Function mean two completely different things. You want function, which is the keyword.
Similarly, there is no such function as Alert(). You'll want to use alert() instead.
The fixed code is:
function test() {
alert(document.getElementById("input").value);
}
Good luck in your learning!
There is a syntax error on your code
the script should be
<Script>
function test() {
alert(document.getElementById("input").value);
}
</script>
both Function and Alert should be in small letters
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Improve this question
I am having an issue with javascript and i don't know how to solve it ...
Actually my code is working good with jsfiddle, but when i try to insert on my HTML page ,it simply doesnt work anymore ...
What i want to, is to add the < li> on < ul> each time i tried to hit the button named "Add" !
HTML code:
....
<td width="50%" valign="top">
<b> SUPER: </b>
<ul id="ul">
</ul>
</td>
....
<input type="submit" value="Add" onclick="add()"/>
....
JavaScript code:
<script type="text/javascript">
function add(){
var ul = document.getElementById("ul");
var li = document.createElement("li");
li.innerHTML = "LoL";
ul.appendChild(li);
}
</script>
The result with that code : it doesn't add anything on my HTML page when i try to hit the button...
Thankfully,
May be oversimplifying this, but here's a thought: Your input button is a SUBMIT, so when the onClick performs, the submit happens immediately thereafter, restoring the page to its original state. The process happens so quickly the appearance is that the code did nothing.
Just change the input type to "button", eg
<input type="button">
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
Javascript
$("#ReadTok").click(function(){
$("#tokentype").load('../process/read_token_type.php');
});
HTML
<input type="button" id="Readtok" value="Read Token" />
<span id="tokentype"></span>
PHP
echo $PartType;
This has worked perfectly for me before why is it not working now.
What am I doing wrong?
Replace your javascript with this one
$("#Readtok").click(function(){ //here t is small letter in ReadTok
$("#tokentype").load('../process/read_token_type.php');
});
Because your button id is id="Readtok"
A typo error. ReadTok vs Readtok
$("#ReadTok").click(function(){
$("#tokentype").load('../process/read_token_type.php');
});
Your ID and Function Selector Name is mismatch thats the problem correct it sure it will work
$("#Readtok").click(function(){
$("#tokentype").load('../process/read_token_type.php');
})
Here one solution.
<Html>
<script type="text/javascript">
$(document).ready(function () {
$("#Readtok").click(function () {
$("#tokentype").load('../process/read_token_type.php');
});
});
</script>
<head>
</head>
<body>
<input type="button" id="Readtok" value="Read Token" />
<span id="tokentype"></span>
</body>
</html>
I hope to help
the id attribute is case sensitive so Readtok and ReadTok are different
either change your javascript to this :
$("#Readtok").click(function(){
$("#tokentype").load('../process/read_token_type.php');
});
or else chage id :
id="Readtok" to id="ReadTok" without altering your javascript