I've got a JQuery click event that doesn't seems to be firing at all. If I am missing something I'm almost certain it's something trivial. I've tried debugging the code via Chrome but the button click on the Filter button is not even hitting the breakpoint.
$('#filter').click(function () {
var dataurl;
var visit = $('#visitFilter').val;
var dns = $('#dnsFilter').val;
var visitdate = $('#visitDateFilter').val;
var entrypage = $('#entryPageFilter').val;
var timeOnSite = $('#timeOnSiteFilter').val;
var timeonsiteselector = $('#timeOnSiteSelector').val;
var pages = $('#pagesFilter').val;
var cost = $('#costFilter').val;
var city = $('#cityFilter').val;
var country = $('#countryFilter').val;
var keywords = $('#keywordsFilter').val;
var referrer = $('#referrerFilter').val;
dataurl = "http://localhost:56971/VisitListFilter/28/" + visit + "/" + dns + "/" + visitdate + "/" + entrypage + "/" + timeOnSite + "/" + timeonsiteselector + "/" + pages + "/" + cost + "/" + city + "/" + country + "/" + keywords + "/" + referrer + "/" + "?format=json";
$('#VisitListTable').bootstrapTable('refresh', {url: dataurl});
});
I've also created a fiddle here with the full code: https://jsfiddle.net/W3R3W0LF666/epu54yc4/1/
Remember .val() is a function.
You need to use () when invoking a function. Currently you are just passing the function reference.
var visit = $('#visitFilter').val(); //Note ()
It is getting fired.
Blockquote
Replace all .val with .val() as .val() is a jquery function for getting values.as :
var dns = $('#dnsFilter').val;
Related
I have the follwoing Jquery code to open page on button click passing a parameter but ? is translated to %3F is there anyways to fix this?
$("#PrintDocument").click(function () {
var grid = $("#Billings").data("kendoGrid");
var row = $("input:checked", grid.tbody).closest("tr");
var item = grid.dataItem(row);
window.location.pathname = '/invoice/billing/Print' + '?productId=' + item.ProductID + '&' + 'runId=' + item.RunID;
});
You are setting the pathname which does not have a query string.
window.location.href = '/invoice/billing/Print' + '?productId=' + item.ProductID + '&' + 'runId=' + item.RunID;
i have a button when i click on this button then whatsapp opens and when i click in a chat and want to send massege then all things come properly but full url not come because & included in my url.
My Url is like this
www.yoururl.com?1st=1&2nd=2&3rd=2&4th=1&5th=2&6th=2&7th=2&8th=2&9th=2&10th=2&share=share&name=s
But sharing in whatsapp then comes only
www.yoururl.com?1st=1
when i remove first & Then url is comes
www.yoururl.com?1st=12nd=2
so i want to share full url with &
Here Is javascript code Code
var url1 = "?1st=" + encodeURIComponent(selectedOption1) + "&2nd=" + encodeURIComponent(selectedOption2) + "&3rd=" + encodeURIComponent(selectedOption3) + "&4th=" + encodeURIComponent(selectedOption4) + "&5th=" + encodeURIComponent(selectedOption5) + "&6th=" + encodeURIComponent(selectedOption6) + "&7th=" + encodeURIComponent(selectedOption7) + "&8th=" + encodeURIComponent(selectedOption8) + "&9th=" + encodeURIComponent(selectedOption9) + "&10th=" + encodeURIComponent(selectedOption10);
section3.style.display="none";
section4.style.display="block";
var u = "www.yoururl.com";
var input = document.getElementById("1nameInput").value;
var inputt = document.getElementById("copytxt");
var inputname = "&name=";
var share = "&share=share";
var text = u + url1 + share + inputname + input;
inputt.value = text;
var $whatsApp = $('.whatsapp a');
decorateWhatsAppLink(text, input);
function decorateWhatsAppLink(text, input) {
// Getting user input
var message = "text";
// Opening URL
var url = 'whatsapp://send?text=';
//define the message text
var textttt = 'dare take this Challenge Now ';
//encode the text
//find the link
var $whatsApp = $('.whatsapp a');
//set the href attribute on the link
$whatsApp.attr('href', url + input + textttt + text);
}
url come from text variable
please tell me how to do
use encodeURIComponent on the whole URI not only the parameter values
so that & gets encoded as well ...
foo = "www.yoururl.com?1st=1&2nd=2&3rd=2&4th=1&5th=2&6th=2&7th=2&8th=2&9th=2&10th=2&share=share&name=s"
foo_final = encodeURIComponent(foo);
I have a setTimout loop being called repeatedly but the loop seems to catch up with itself and causes sticking on my page ect. I added a alert to see what was happening and i had the timer set to call every 10seconds, but the alert was being displayed oppressively faster until it was continuous
can anybody see why this is by my code below.
Many thanks
$(function(){
var running = setTimeout(function (){
var varLISTID = document.getElementById('datacatch').getAttribute("data-variable-LISTID");
var varUSERACCOUNTNAME = document.getElementById('datacatch').getAttribute("data-variable-USERACCOUNTNAME");
var varITEMACCOUNTNAME = document.getElementById('datacatch').getAttribute("data-variable-ITEMACCOUNTNAME");
var varSELECTEDUSER= document.getElementById('datacatchuser').getAttribute("data-variable-SELECTEDUSER");
var mylink = "loadmessages.php?listID=" + varLISTID + "&useraccountname=" + varUSERACCOUNTNAME + "&itemaccountname=" + varITEMACCOUNTNAME + "&selecteduser=" + varSELECTEDUSER;
$('#infobox1').load(mylink);
var myotherlink = "contactselect.php?listID=" + varLISTID + "&useraccountname=" + varUSERACCOUNTNAME + "&itemaccountname=" + varITEMACCOUNTNAME + "&selecteduser=" + varSELECTEDUSER;
$('#containercontact').load(myotherlink);
},10000);//10s
$(document).keypress(function() {
clearInterval(running);
})
});
I'm trying to assign a value to an input that has a name that is dynamically generated but I can't seem to access the input's value
This is what I'm doing:
function calcCorrectedTo(input){
var name = input.name.split('_');
var value = input.value;
var targetName = name[0] + '_' + name[1] + '_4_' + name[3] + '_' + name[4] + name[5];
var correctedTemperature = calcCorrectedDissipation(10, value);
var target = $('input[name=' + targetName + ']').val();
}
function calcCorrectedDissipation(temp, value){
debugger;
var dissipationFactor = Math.pow(0.5, ((20-temp)/31));
var correctionCoEff = 1/dissipationFactor;
return (parseFloat(value) * correctionCoEff);
}
HTML:
<input type="text" name="icdf_1_3_-1_6077_-1" val="" class="tableInputBox" onblur="calcCorrectedTo(this);">
I've stepped through the code and the targetName is generated correctly so I'm assuming I'm doing something wrong on the line where I'm looking for the input. Any suggestions on what I'm doing wrong?
Without knowing what your HTML looks like, I think you're missing quotes around your targetName. Typically, jQuery would access an html input like this
$('input[name="somename"]')
In your case, you should do this:
$('input[name="' + targetName + '"]').val(correctedTemperature );
The bug is you are generating the name wrong.
var targetName1 = "icdf_1_3_-1_6077_-1";
var expected = "icdf_1_4_-1_6077_-1";
var name = targetName1.split('_');
var targetName = name[0] + '_' + name[1] + '_4_' + name[3] + '_' + name[4] + name[5];
console.log(targetName===expected);
console.log(targetName.length, expected.length);
console.log(targetName);
console.log(expected);
and the output
false
18 19
icdf_1_4_-1_6077-1
icdf_1_4_-1_6077_-1
Simple console.log saves the day.
I am so close to getting this. Here's my code that is returning the correct url, but only when button is double-clicked. I only need one click to retrieve the image.
var origin = 'COMP';
var area = 'US';
var type = 'typeA';
var level = 'Xnay';
var time = '0';
var btn1 = document.getElementById("redbutton").winControl;
function change_area(new_area) {
area = new_area;
}
function change_type(new_type) {
type = new_type;
}
$(btn1).click(function () {
var src = "http://somesite.net/folder/WEB_" + origin + "_" + area + "_" + level + "_" + type + "_" + time + "HR.png";
change_area('GB');
change_type('typeB')
$('#mainmap').attr('src', src), false;
});
You try by adding
$(document).ready(function() { }); block
before the following line
$(btn1).click(function () {
Finally as,
$(document).ready(function() {
$(btn1).click(function () {
var src = "http://somesite.net/folder/WEB_" + origin + "_" + area + "_" + level + "_" + type + "_" + time + "HR.png";
change_area('GB');
change_type('typeB')
$('#mainmap').attr('src', src), false;
});
});