How to create checkbox-based price calculator? [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 8 years ago.
Improve this question
Can you please give me examples how to create price calculator based on which checkboxes are selected using JS and jQuery.

Something like this?
https://jsfiddle.net/hof63n3k/
HTML
<input type="checkbox" value="1.99"> $1.99</input><br/>
<input type="checkbox" value="2.99"> $2.99</input><br/>
<input type="checkbox" value="3.99"> $3.99</input><br/>
Total: $<span class="total"></span>
JQuery
$(function() {
$('input').click(function(){
var total = 0;
$('input:checked').each(function(index, item) {
total += parseFloat(item.value);
});
$('.total').text(total);
});
});

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>

How to put variable inside a innerHTML tag in 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 5 years ago.
Improve this question
var item = document.getElementById('drpItem').value;
var createDiv = document.createElement('createDiv');
createDiv.className = 'row';
createDiv.innerHTML = '<input type="text" name="name" value="item" />
Try like this .'string'+variable+'string'
createDiv.innerHTML = '<input type="text" name="name" value="'+item+'" />

display the name of the image using onchange="readURL(this);" [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
preventDefault() and onchange() together will not display image file name what do i need to do for this to work? how can i get rid of preventDefault()?
jQuery("#btn-Preview-Image").click(function(e) {
e.preventDefault();
renderContent();
jQuery("#download").removeClass("disabled");
});
jQuery("#download").click(function(e) {
e.preventDefault();
return jQuery(this).hasClass("disabled");
});
this is input with onchange():-
<input type="file" name="file1" id="file1" onchange="readURL(this);"/>
Due to security reasons browsers doesn't allow to get selected file original path.
What else you can get is given in below example:-
$('input[type=file]').change(function () {
console.dir(this.files[0]);
console.dir(this.files[0].name);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="file" name="file1" id="file1"/>

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()">

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