html5 to javascript use in put value of html in javascript [closed] - javascript

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 8 years ago.
Improve this question
This is the javascript code forming a chart
series: [{
name: 'Year 1800',
data: [ 22 , 23, 635, 203, 2]
},
and this is HTML5 code
<input type="number" id="num1" value="222" min="1" max="20" />
I want to use this input value in the data section of javascript replacing the 22 value in the chart.

Probably you will want to get the value from the input first:
document.getElementById('num1').value
and then use it in your chart, for more details you should supply more information.

Related

When I click on the button it shows me an error [closed]

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 last year.
Improve this question
The error ReferenceError: b is not defined at HTMLButtonElement.onclick (/:32:30)
let s;
function b(){
s = document.getElementById(k).innerHtml;
animates();
}
<form class="form">
<label>How much do you want to donate</label>
<input type="number" id="k">
<button id="l" onclick="b()">Cal</button>
</form>
no need to do a form for this, also inline events are not preferred use eventListeners in js.
NOTE: I've put input's value as result, but you didn't say what you exactly want, so I think this will work with you anyway
document.getElementById('l').addEventListener('click', function() {
document.getElementById('result').innerHTML =document.getElementById('k').value;
})
<label>How much do you want to donate</label>
<input type="number" id="k">
<button id="l">Cal</button>
<p id="result"></p>

KeyPad numbers in javascript on click event [closed]

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 1 year ago.
Improve this question
I have this created a page with numbers and textbox in top of it as you see in the picture
The element id of the textbox is t1
the question is , what's the code I should write on click event to make the numbers written on the textbox .
For example , when I click (1) three times , the textbox should have the value of ( 111 )
any advices ?
JavaScript:
function display(val)
{
document.getElementById("t1").value+=val
}
HTML:
<input type="button" value="1" onclick="display('1')"/>
<input type="button" value="2" onclick="display('2')"/>
<input type="button" value="3" onclick="display('3')"/>
And so on..
display() will call the function to display the value what has been clicked.

Try GetElementsByClassName [closed]

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 2 years ago.
Improve this question
try js ref_doc_getelementsbyClassName
"Uncaught TypeError: Cannot set property 'value' of null "
This HTML code
<input type="text" class="form-control" class="test" />
This JS code
function inputtest() {
document.getElementsByClassName('test').value = selectedControl;
}
Change your html:
<input type="text" class="form-control test" />
JS
function inputtest() {
document.getElementsByClassName('test')[0].value = selectedControl;
}

Using Html input pattern (500/600) [closed]

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 7 years ago.
Improve this question
I want the following pattern in my Html text box : 500/600
i Have wriiten the following html code for it but its wrong
<input type="text" placeholder="eg: 500/600" name="txtShscpercent" pattern="[0-9]+\.[0-9]+[{\|\}]+[0-9]+" required></td>
can anyone help me with this
Whole numbers:
<input type="text" placeholder="eg: 500/600" name="txtShscpercent" pattern="\d+\/\d+" required>
Decimals:
<input type="text" placeholder="eg: 500/600" name="txtShscpercent" pattern="\d+(\.\d+)?\/\d+(\.\d+)?" required>

jQuery .val using ID selector undefined [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
<form action="javascript:message();">
<input type="text" id="#msg" value='test'>
</form>
This is a simple form I made. Now when I call my JS function using this code it works (only one input can be accessed though):
function message() {
alert($('input').val());
}
But using this code doesn't work (alerts Undefined):
function message() {
alert($('#msg').val());
}
I have really no clue what to do and I have been looking for hours...
The value of the id attribute shouldn't start with a #:
<form action="javascript:message();">
<input type="text" id="msg" value='test'>
</form>
Here's the fiddle: http://jsfiddle.net/XrJjU/
If, for whatever reason, there is a # in the id, you'll have to escape it in your selector:
$('#\\#msg').val();
Here's the fiddle: http://jsfiddle.net/7P5ER/

Categories