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 5 years ago.
Improve this question
Here I need to provide officename to find the address ,but one challenge which I am facing that if user does not type anything and hit search button then I want to acknowledge them to fill the req input.
I have implemented one function also that will get invocked when someone hits the search button.But I am unable to proceed for further execution.
You can do it something like this:
var searchText = document.getElementById('<ID_OF_INPUT_FIELD>').value;
if(!searchText) {
alert('Please enter something');
}
<input id =“officeInput” name=“officeiupit” size=“35”>
Point to critical input fields and save in global variables:
oOf=document.getElementById(‘officeInput’);
When a search button has been clicked, make a copy of the textbook content inside your function which you've made:
var sInputText=oOf.value;
In this case inside your function just put
if(!sInputText)
alert(“You must enter an input.“);
Related
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
I did create a Html form tag and Html button tag.
Now I want to create again form tag when the user clicks my button
I think this is possible with JavaScript
If anyone knows please help me
Thanks
Here is a sample code. This will add the form once.
let form = document.getElementsByClassName('sample-form')[0]
//make copy of the original form using cloneNode(true). true means JS will copy all the nodes inside of the form element. It's called "deep copy".
function duplicateForm(){
return form.cloneNode(true);
}
let addForm = document.getElementById('add-form')
addForm.addEventListener('click', function(){
document.body.append(duplicateForm())
})
<form class="sample-form">
<input placeholder="Your value here"/>
</form>
<button id="add-form">Add New Form</button>
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
enter image description here
1)Make up the design below
2)License type output in Bebas font-output via font-face
3)Display the selected license type and total amount
4)The format of the link in the Buy Now button is formed at your discretion
(How to execute an item highlighted in italics)
You need to have an HTML element (like a paragraph) where you want to display the amount.
If you give the element an id attribute with the value "my-paragraph", then your script can get the element like myParagraph = document.getElementById("my-paragraph").
Then you can change the content of the element like myParagraph.textContent = myAmount.
Begin your learning journey on MDN: https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model/Introduction
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 5 years ago.
Improve this question
Apologies for a long title, I'm a beginner but what I want to achieve should be pretty simple to do, I think :)
I have a button on my website that points to a link, let's say mysite.com/abc=$userid
Once the button is clicked the prompt should open up and ask the user for their email address. After they input and press ok/submit I'd like to take their input and replace $userid with it e.g. mysite.com/abc=john#mail.com and open this link in a new tab.
Hope the question makes sense and I'd be eternally grateful for any tips on how to achieve this. Please help.
Kind regards,
Jack Dunn
Quick jquery solution as this answer is marked with jQuery tag :
$('#myButton').click(function() {
var email = prompt('Please enter your email');
if (email != null) {
location.href = location.href + "?abc=" + email
}
});
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
So I am trying to do a button and if you click on it then it calls a function called order(). So, If I'm trying to do something like this order("+<script>blablabla</script>+") then it shows me a error if I type into something between the "+HERE+" Why that? Is there any way around it?
You could always do something like this. Maybe change the divs around a bit and add a rounding system. This gives you a live update on the costs when selecting how many keys.
https://jsfiddle.net/8hube9ua/
Throw this under your select,
<span data-val="1.85">1.85</span> <!--How much each key is-->
then throw this into the script.
<script>
$('#suiface').change(function(){
var span = $(this).next('span');
span.text(span.data('val') * parseInt(this.value,10)) //multiplies the cost by the option selected
})
</script>
I'm not sure to understand, but why don't you write something like this ?
<button onclick="order()">Blablabla</button>
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 7 years ago.
Improve this question
I am trying to build a chatbox for my friends to use and before a friend can join the room I want them to click on a bottom which has a default value of JoinChat. AND when they click that I want to send request to the database using ajax to allow them enter the room and then change the value of the bottom to LeaveChat
Assuming they have entered the room and they wan to leave the room so when they click on the same bottom, send another request to database to disconnect them from the chat room.
<input type="button" value="JoinChat" onClick="" id="btn">
Here is quick solution:
var isConnected = false;
var NOTCONNECTEDTEXT = 'JoinChat'
var CONNECTEDTEXT = 'LeaveChat'
function btnClick(event){
isConnected = !isConnected
document.querySelector('#btn').value =
isConnected ? CONNECTEDTEXT : NOTCONNECTEDTEXT
}
<input type="button" value="JoinChat" onClick="btnClick()" id="btn">
Just implement what you need, but the code is bad, to improve the code, recommend you use library like React.