We have a registration form that uses jQuery-Calx to auto calculate the total of the selected items and would like to store the option value in a database after the form is submitted.
How should we define the value used in the calculation to do so? We want to calculate but also want to store “Event Name” if chosen into the database.
We have made some progress trying to follow comments here - http://www.xsanisty.com/project/calx2/comment-page-2/#comment-5678
Here is one of the drop down menus:
<select class="form-control" name="####" data-cell="A1">
<option value="0">Please select</option>
<option value="Event Name 15" data-next="15" >Event Name $15</option>
<option value="10">Ten</option>
</select>
Here is script (not working):
$('#registration').calx({
data:{
A1:{ value: $('[data-cell="A1"]').attr('data-next')}
}
});
We are trying to calculate the total of 5 drop down menus based on the "data-next" value instead of the select option value.
So we can then enter the option value "Event Name" into a database using php (we know how to do this part)
Thank you for any help.
Related
I want to set re-select option in , I know there is a function to do that for single element using javascript but I use it as an array so I need to set the value inside the loop su as this example:
<select name="days" value = "3">
<option value="1">Sat</option>
<option value="2">Sun</option>
<option value="3">Mon</option>
<option value="4">Tue</option>
<option value="5">Wed</option>
<option value="6">Thu</option>
<option value="7">Fri</option>
</select>
I think this example will work fine with react, but can I use such a code in normal html and javascript inside the loop.
if you have a database store the day value, instead of use if else function, filter the day on select tag to make the option selected as value in database
basically inside foreach there is a select option tags I need to set selected using the value in database like so:
$('#dynamic_field').append('<select><option value="1">Sat</option><option value="2">Sun</option> ..... </select>
Thanks
In the end of the loop:
$('select[name^=day]',item.id).each(function(a,b){ $(b).val(item.day); });
with that will check for each value and set the value in the database as selected in select form
*Note: item.id and item.day came from database
I have a dropdownlist with a list of countries (all countries)
<select id="Country" onchange="country();">
<option id="3">Japan</option>
<option id="4">Canada</option>
<option id="5">France</option>
<option id="6">Peru</option>
</select>
I have the form in a modal that i want get country value from.
<input id="seachcountry" type="text" class="form-control" name="country">
I have written a JQuery line to get the value from the modal form to the page fields, everything works great but the country select fields are not changing the value.
$("#seachcountry").val($("#modalform").val()).trigger("change");
thank you for your suggestions!
This will work for you:
Just inject the value of the <input> to <select>.
I have created a snippet for you.
var Tval = $('#seachcountry').val();
$('#Country').val(Tval);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<select id="Country" onchange="country();">
<option id="3">Japan</option>
<option id="4">Canada</option>
<option id="5">France</option>
<option id="6">Peru</option>
</select>
<input id="seachcountry" type="text" class="form-control" name="country" value="France">
Try this.
function country() {
$("#seachcountry").val($(this).val());
}
For changing value in any select you just need send exist value from this select. In your select options have only ids, but not have value attribute. So if you add value equal to id to change value in the your form to "France" need run following:
$("#selectId").val(5)
Instead of 5 you can obtain value from any other field or else.
If you want set your value to input field when changed in select, you need attach listener that will do all work. It will looks like this:
$("#selectId").on("change", function(){
$("#inputFieldId").val($(this).find(":selected").text());
})
This will set displayed value to select, to set real value just write instead $(this).find(":selected").text() this $(this).val()
I have a set of input boxes and you can add more and more sets of these forms if you click the add more button. In my form I can submit data and I have got it to show up when you reload the page. However, I am stuck at making sure all of the fields have values before I run my AJAX. I use Jquery for this project
I cannot use a validation plugin because I am running magento and every time I try running the plugins in "No Conflict Mode" the plugins do not seem to work. Because I am running Magento this means I need to run Jquery in no conflict mode.
I have seen other solutions for this however they are all to do with input boxes and I have 1 input boxes and 2 select boxes. How can I make sure that all the input boxes are filled before and that all the select boxes that are not disabled have something selected before the ajax call?
Here is part of my HTML:
<form>
<input id="12">
<select id="1">
<option disabled="disabled" selected="selected">select please</option>
<option value="01">Option 1</option>
<option value="02">Option 2</option>
</select>
<select id="2">
<option disabled="disabled" selected="selected">Select Please</option>
<option value="01">Option 1</option>
<option value="02">Option 2</option>
</select>
Using a click event, if you use .val() on your <select/>, it will return null if there is no value attribute on your <option/>.
Note: This will not work if you put a value attribute on your options.
Edit: Doing a !== compare will be faster.
$("#submit-button").click(function(){
//if this is true, then it is valid
alert($("#1").val() !== null);
});
You can do it by getting the inputs value into a property.
This script would alert the number of how many inputs aren't complete or missing with base in your structure.
(no jQuery)
var myForm=document.getElementsByTagName("form")[0];
var formSelectors=myForm.getElementsByTagName("select"),
formTextBoxes=myForm.getElementsByTagName("input"),
missing=0;
var i,
length=formSelectors.length;
for(i=0;length>i;i++){
if(formSelectors[i].value===formSelectors[i].children[0].value)
//Check if select value is equal to
//select please or Select please
//MISSING! (select)
missing++
}
length=formTextBoxes.length;
for(i=0;length>i;i++){
if(formTextBoxes[i].value.length===0)
//MISSING! (input)
missing++
}
alert(missing)
Try this:
if($('#12').val()!='') {
// your code
}
I got an interface, already logged in with a new username now I want so select this user to my selected option value and insert it into Mysql DB:
<select name="name" class="form-control" required="required">
<option value="" required="required"> Please select </option>
<option value="Rifadije Mavriqi"> Rifadije Mavriqi </option>
<option value=" <?php
?>"></option>
<option value="Merdiana Leci"> Merdiana Leci </option>
</select>
Let say that your working with CronJobs that every X minutes check whos online, than select the column where online=1 with simple while and you got it.
Okay, i dont know if you ever work with cronjobs, thats really easy, via your cpanel/direct admin you pick up a file and set-up every x time the server will run this file. Let call this file cronj.php and there write a query that set all the online colum to 0 ( than unactive users resets) and close the file. I will add in a config or header file a query that check if this is user or unregister guy , if register lets set online colum to 1. And now via your control panel write select query with while that show you where online=1 and show you by the online colum the user names that online right now.
I have an ng-repeat that creates a table of data. Each entry has several properties, including IP Address, MAC Address, author and more. I have a textbox that automatically sorts IP address, but I also want to provide a dropdown that allows users to select which property they would like to filter by.
For example, the default behavior is that by typing "12" into the box, only entries with "12" in the IP Address will be displayed. But if the user selects "Author" from the dropdown and types "Mark" into the textbox, only entries with "Mark" as the author will be displayed.
I tried setting the textbox's ng-model to "selectFiler.value" but that didn't work.
<form>
<select ng-model="selectFilter">
<option value="incident_at">Incident Date</option>
<option value="ip_addr" selected="selected">IP Address</option>
<option value="mac_addr">MAC Address</option>
<option value="created_at">Created On</option>
<option value="author">Author</option>
<select>
<input type="text" placeholder="Search by IP" ng-model="filterTable.ip_addr">
</form>
Here's some code, but because I'm using ui-router and templates for the full project I can't get the data to display in Plunker:
http://plnkr.co/edit/kNqx1g3HidEM0ORzsSJt?p=preview
How can I make this work?
Try using typeahead from angular-bootstrap library.