mardi 31 juillet 2018

Javascript, form values

I have some variables in Javascript if statement which capture the values in a form. A check box and a couple of drop downs. Is there any way I can make the variables a bit dynamic? For example, if the user decides to select a different option then the value updates? At the moment it only captures what is currently selected on page load.

if(document.URL.indexOf("page") >= 0 && document.cookie.search('myCookie') < 0){ 


var productvalue = document.querySelector('input[name=product]:checked').value;

var amount = document.getElementById("frm-amount");
var amountValue = amount.options[amount.selectedIndex].value;

var term = document.getElementById("frm-term");
var termValue = term.options[term.selectedIndex].value;

Aucun commentaire:

Enregistrer un commentaire