Can i somehow insert number multiple times into input? [closed] - javascript

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 10 months ago.
Improve this question
this code while i click two times: 2
what i need: 11
<div id='one'></div>
<input type="number" id='pin'/>
<script>
document.getElementById('one').onclick = document.getElementById('pin').setUp(1);
</script>

<div id='one'></div>
<input type="number" id='pin'/>
<script>
var one = document.getElementById('one');
var pin = document.getElementById('pin');
one.onclick = function(){
pin.value = pin.value + '1';
}
</script>

Related

Search google for text entered in an input field [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I'm looking to make a Google search bar for a website I am creating. I would like to search Google for the text entered in an <input> tag. Any help would be greatly appreciated.
Try something like this
<script>
function googleSearch()
{
var text=document.getElementById("search").value;
var cleanQuery = text.replace(" ","+",text);
var url='http://www.google.com/search?q='+cleanQuery;
window.location.href=url;
}
</script>
<input type="text" id="search" />
<button onclick="googleSearch();">Search</button>

trying to implement a js color picker that changes the background of a html5 document [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
<script src="jscolor.js"></script>
var Color: <input class="jscolor" value="ab2567">
<script>
colorObject.value=#Color;
colorObject.value
document.body.style.backgroundColor==(Color)
</script>
here is the file jscolor.js, https://www.dropbox.com/s/qmvy2vzmin3z01h/jscolor.js?dl=0
Any help is much appreciated, thanks!
You need add event listener to do that.
See my snippet below:
function changeColor() {
var jsColor = document.getElementsByClassName('jscolor')[0];
document.body.style.backgroundColor = '#' + jsColor.value;
}
<script src="http://jscolor.com/release/latest/jscolor.js"></script>
<input class="jscolor" value="ab2567" onchange="changeColor()">

What is wrong with my code for a basic calculator? [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 8 years ago.
Improve this question
I'm trying to program a calculator, but I can't find the bug in my code. Here's my code:
<html>
<head>
<title>*</title>
</head>
<body>
<form>
<input type="number" placeholder="Enter a number" id="val1"><br>
times<br>
<input type="number" placeholder="Enter a number" id="val2"><br>
<input type="button" value="Calulate" onClick="myFunction()">
<script>
function myFunction(){
var val1 = document.getElementById(val1)value;
var val2 = document.getElementById(val2)value;
var result = val1*val2;
alert("The result " + result);
}
</script>
</form>
</body>
</html>
If you know how, and want to, can you help me to make it a calculator for +,-,:,* etc all in one? Thank you very much!
You are missing a dot(.), and the selector is wrong use "#id" for ids and ".class" for classes.
var val1 = document.getElementById("#val1").value;

get a variable from a textarea in javascript [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 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

Edit a disabled input field with javascript [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I have a disabled field that I want to edit with the below script
<html>
<select id="country"onchange="changeCountryCode()">
<input type="text" disabled id="cc">
<script>
function changeCountryCode()
{
var temp = $('country').val();
$('cc').val(temp);
}
</script>
</html>
It's not working for me.
What you have almost works but you are missing the # in your selectors. The # sign tells jQuery to use the ID attribute when looking up the element desired.
Should be:
var temp = $('#country').val();
$('#cc').val(temp);

Categories

Resources