I am using the star rating from this site : link
But I can't seem to figure out how to get the rating from my radio buttons.
I just need to display it in the console.log, the rest I can manage.
When the third is selected it looks like this:
If any more information is required, please ask, new to this.
Get number of stars with the selected class .star-rating-on:
var rating = $('.star-rating-control .star-rating-on').length;
If there are more than one set of rating controls, please use a different parent selector, like article or .post:
$('article').each(function() {
var rating = $(this).find('.star-rating-control .star-rating-on').length;
// Do something...
}
Please use following code to get the value of rating:
$('.auto-submit-star').rating({ callback: function(value, link){ alert(value); } });
Replace .auto-submit-star with your selector
The simple way is
Create a form. Form will help you to post rating data.
inside form create radio buttons as per your need.
Call javascript api to change radio buttons into stars.
There are 2 ways to get data from rating
a. submit a form and get result using $_POST or $_GET or $_REQUEST
b. Use ajax
Note:- This plugin return selected radio button value.
Related
I have a drop-down menu in a form with elements retrieved from a database. Something like this :
for($i=0;$i<count($resq);$i++){
print("<li><a class=\"dropdown-item\" href=\"#\" id=\"$i\">{$resq[$i][0]}</a></li>");
}
$resq being an array containing the result of the query (i used mysqli_fetch_all).
As you can see I tried to dynamically generate the id of the items(first item has id=0, second has id=1 and so on till the final value of $i) but I think this is not correct.
Previously, I had the following JS code(which worked) which I used to set the drop-down value to the one selected by the user and to set the value of a hidden input to that value.(I know the code isn't elegant but I just wanted to test the logic in the first place)
var x=document.getElementById('dropdownMenuButton1slct');//dropdown
var c1=document.getElementById("0");//i - categories(IDs of the dropdown elements)
var c2=document.getElementById('1');
var c3=document.getElementById('2');
var c4=document.getElementById('3');
var c5=document.getElementById('4');
var p=document.getElementById('iaval');//hidden input from form
function clic(z){
z.onclick=function () {
x.innerHTML=z.innerHTML;
p.value=x.innerHTML;
};
}
clic(c1);
clic(c2);
clic(c3);
clic(c4);
clic(c5);
But now the same method won't work. If you can, please suggest me a different way or something, I am kinda stuck. I can provide more info if this seems vague or something like that. Thanks.
Hi i use w3schools autocomplate tutorial. Link https://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_autocomplete
I want to make multi choose. For example ; France and England for Country. Actually i saw multi choose example on Javascript but i need a variables. When i click send button my query executed so i need variables.
How can i do it ? and how can send value from input area to sql query ?
Image
It is difficult to understand what you're looking for in the way you phrased the question, but I will try answer based on how I understood the question.
First, I would add hidden input to contain array values under input ID: #myInput.
Try the following:
<input id="countries" type="hidden" value="countries[]" />
<input type="button" value="add" onclick="addCountry">
As you see, I bind click event to the button so function would be:
function addCountry(){
const countries = document.querySelector('#countries');
const country = document.querySelector("#myInput");
countries.value = [...countries.value, country.value];}
So, when you submit form, you will be able to get this from a PHP file
with []
$countries = $_POST['countries'];
Alternatively you can use $_GET instead.
So let us say i have a form with id #form which has two input fields, namely title & price.
I click on the Edit button somewhere in the application which has data attributes (e.g data-title="Apple" data-price="10")that are to be assigned to the #form upon clicking the button.
the obvious solution that works is
$("#name").val($(this).data('name'));
$("#price").val($(this).data('price'));
This obviously looks bad when you have too many fields. So I am trying to get something like this to work $('#form').data($(this).data());, more or less in a single like
Have tried this many ways with no success
Any help is appreciated
You could create a jquery plugin that you can call from the element that contains the data points and have it apply the data based on the key to elements within the form of that same name. Example below
$.fn.applyData = function(form) {
$form = $(form);
$.each($(this).data(), function(i, key) {
$form.find('#' + i).val(key);
});
};
JSFiddle: http://jsfiddle.net/LCM8S/43/
I'm using VisualSearch.js. Works great out of the box but my interface has a list of links. When user clicks on one of these it will add a facet & value (i.e. tag:cats) to the search box and trigger the search taking into account any other search inputs that are already there.
I don't see a clear way to do this from the source code - Am I missing something? http://documentcloud.github.com/visualsearch Thanks for any help!
I figured it out - using the addFacet method from visualSearch.js - like this:
//add a tag filter
visualSearch.searchBox.addFacet('tag', tag.name, 0);
You should find the addFacet function in search_box.js like below:
addFacet : function(category, initialQuery, position) {
"category" will be facet's name, "initialQuery" will be the pre-populate value.
im having a set of multiple check bxes, like one set contain 3 check box share same name another set contain 3 check sharing same name . how can i get the value of these two different set of check box using a single code .
var form = $('usersurvey');
checkboxes = form.getInputs('checkbox');
for(count=0; count< checkboxes.length; count++){
if(checkboxes[count].checked){
retValue=true;
break;
}
}
return retValue;
}
im tried with this code but it fetch all the check boxes , i want only that have the same name, i used prototype.js
if you give each set of checkboxes a different class you could select them using jquery like:
$(".className").each(function(index, element) { ... });
for instance. somebody may be able to improve on this solution by selecting by name (i wasnt sure if you could do that, i always just select by class).
EDIT: sorry i should elaborate probably. the $(".className") piece will select all the checkboxes of class 'className'. since it sounds like you want to DO something with each of them though, i just added the each call on the end. inside the each call, you can define a function (shown) that will do something for each checkbox that was selected. reference the jquery each docs here:
http://api.jquery.com/each/