x = document.getElementById("numb").value; [closed] - javascript

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
x = document.getElementById("numb").value;
i don't understand what ".value" means?
i have already tried to find solution from google and past questions of javascript.
so please tell explanation for better understanding.

value here is a property of the Element Object returned by getElementById.
As you can see at this link, this is a property of almost all HTML form elements, such as <input> fields.

.value means that you get the value assigned to a HTML element. For example:
<html>
<head>
<script>
function getName()
{
var x = document.getElementById("numb").value;
msgbox(x);
}
</script>
</head>
<body>
<input type='button' value='Get Name' onclick='getName()'/>
<input id='numb' type='text' name='myname' value='5'/>
</body>
</html>

Related

how to get a placeholder value in js [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 1 year ago.
Improve this question
how to get a placeholder's value in javascript
I don't want JQuery to get the value
can anyone tell how to get it
const ip = document.getElementById("ip").getAttribute('placeholder');
console.log(ip);
<input type="text" placeholder="some value" id="ip">
You can use the getAttribute() method to get the value of an attribute of a DOM element. MDN - Element.getAttribute()
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
function myFunction() {
var x = document.getElementById("myText").placeholder;
console.log(x);
}
</script>
<html>
<body>
First Name: <input type="text" id="myText" placeholder="Name">
<p>Click the button to view the placeholder content in console.log</p>
<button onclick="myFunction()">Click Here</button>
</body>
</html>

HTML Searching on the same page [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 have one long page of content. If I want to create a search bar so that when the user searches something that exists somewhere on the single page, it redirects them to that part of the page (like it goes to the middle or the bottom of the page). Does this require any back-end like PHP or can I do this with just HTML?
You can make use of window.find() in JavaScript
Reference: https://developer.mozilla.org/en-US/docs/Web/API/Window/find
Demo:
function search(string){
window.find(string);
}
<input placeholder="type foo or bar" type="text" id="search">
<input type="button" value="Go" onclick="search(document.getElementById('search').value)">
<br><br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br><br>
<br><br><br><br><br><br><br><br><br><br><br><br>
<p>foo</p>
<p>bar</p>
<p>hello world</p>
Easiest thing to do would be some javascript
<input id="searchText"><button onclick="search()">Search</button>
<script>
function search() {
var searchText = $("#searchBar").val();
$(".searchText:contains('" + searchText + "')").css("background","#FF0");
}
</script>
<div class=".searchText">Some kind of text would go here</div>

link button using html5 [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 8 years ago.
Improve this question
I want to create a button which allows me to go to a link entered in an input filed.
So this is what I did but it does not work.
<html>
<head>
</head>
<body>
<form action="link">
link : <input type="text" id="link">
<input type="button" value="go" onclick="self.location.href = 'docuement.getElementById('link').value'"/>
</form>
</body>
</html>
What should I do?
Don't use a string literal, get rid of the ' from around the value you assign to self.location.href.
Spell document correctly
You should avoid using self as well, it is an unnecessary level of indirection.
<input type="button" value="go" onclick="location.href = document.getElementById('link').value"/>
Things fixed:
fix spelling of document
unquote the expression to be evaluated
don't bother with self

Call function on pass input in textbox [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 want to call the function in every input pass on textbox, but it does not work., either when i enter any input or remove input..it is work like intellisense textbox
<input id="btnSearch" type="text" value="Search" class="search_btn" onchange="Call()" />
<script>
function Call()
{
alert("Me");
}
</script>
Probably what you want to do is -
<input id="txt_Search" type="text" onchange="Call()" />
<script>
function Call()
{
alert("Search suggestions can come here!!");
}
</script>
Or, using simple jQuery
$("#txt_Search").keyup( function() {
var searchQuery = $("#txt_Search").val();
alert("Seacrh suggestion satrting with - " + searchQuery);
});
you can also use textbox events -
<input id="txt1" type="text" onchange="SetDefault($(this).val());" onkeyup="this.onchange();" onpaste="this.onchange();" oninput="this.onchange();">
jquery -
function SetDefault(Text){
alert(Text);
}
Try This

How do I insert html tag inside of script? [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
How do I insert html tag inside of script?
Here is how I'm trying:
document.Tick.Clock.value=hours+"<span>:</span>"+minutes+":"
Original:
document.Tick.Clock.value=hours+":"+minutes+":"
Since your html element has a value property I assume it's an input. If it is then you can set the value including html tags:
<input type="text" id="mytext" />
<script>
document.getElementById("mytext").value="<p>helo</p>"
</script>
If your html element is not an input element then you should set innerHTML:
<div id="mytext"></div>
<script>
document.getElementById("mytext").innerHTML="<p>helo</p>"
</script>

Categories