Why url query string doesn't pass a variable value? [closed] - javascript

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 6 years ago.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Improve this question
I am trying to pass a parameter in query string i.e._type=1 but it doesn't pass. It doesn't appear in URL, other values does but not this one. Why ?
SitePaymentReportByBranch = function () {
$('#btnprintSitePaymentByBranch').on('click', function (e) {
e.preventDefault();
if ($("#form1").validationEngine('validate')) {
var _employerID = "";
if ($('#cmbEmployerSitPaymentByParameter :selected').text() == "-Select-") {
alert('Plz Select Employer');
}
var url = '/Reports/frmSitePayment.aspx?_EmployerID=' + $('#cmbEmployerSitPaymentByParameter :selected').val() + '&_Formdate=' + $("#formdate").val() + '&_Todate=' + $("#todate").val() +'_type=1';
commonStartup.openReportWindow(url);
}
});
},

You missed & before _type fix will be '&_type=1'
var url = '/Reports/frmSitePayment.aspx?_EmployerID=' + $('#cmbEmployerSitPaymentByParameter :selected').val() + '&_Formdate=' + $("#formdate").val() + '&_Todate=' + $("#todate").val() +'&_type=1';

Query parameters must be separated with &. You have omitted this for your _type parameter:
'_type=1'
should be;
'&_type=1'

Related

Why Javascript replace is not working in this case [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
I have got a string with #! and i want to replace the #! with empty .
This is my code
$(document).ready(function () {
var uri = 'ghgfhf'
if (uri.indexOf("#") > 0) {
var clean_uri = removeURLParameter(uri);
console.log(clean_uri);
}
});
function removeURLParameter(url) {
url = url.replace(/!#/,'');
return url;
}
Could you please let me know how to replace the #! with empty ('')
"!#" should be "#!"
function removeURLParameter(url) {
url = url.replace(/#!/,'');
return url;
}
See updated jsfiddle

how to find and replace text url with links in jquery [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
Hi I want to find text url in my editor and convert them to anchor tag links using jquery.
here is my code
function urlify(text) {
var urlRegex = /^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/;
return text.replace(urlRegex, function(url) {
return '' + url + '';
})
}
$("#queEditor").bind('input propertychange', function(){
var url = urlify($("#queEditor").text);
console.log(url);
});
But it's giving an error undefined function text. Could someone help me rectify this?
Since .text() is a function you need to use () when you want to invoke it.
$("#queEditor").text(); //Notice ()

How to pass value for the JavaScript statements? [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I want to pass a value to a Javascript Statement. Is it possible?
For Example :
function Show(msg, Id, Msgtype) { // I need to pass this Id argument to below javascript innerHtml statement
var strVar = "";
strVar = "Hello" + Msgtype + " <i class='icon-remove close'></i> " + msg + "</div>";
document.getElementById("???").innerHTML = strVar; // ??? should be the Id above in the function arguments
}
Or in other way, how can I achieve this scenario?
Just pass Id, like this
document.getElementById(Id).innerHTML = strVar;

Javascript eval in function [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Improve this question
I want to make a function that has to generate a random number between 2 numbers and you can save it in a variable. I'm using this code:
function rand(ran1, ran2, randVar) {
var randomNumb = Math.floor(Math.random()*(ran2 - ran1)) + ran1;
eval("var " +randVar+ " = "+randomNumb+";");
}
rand(12, 49, rand1)
alert("Your number is: "+rand1)
The error I get is: Can't find variable: rand1
Can anyone help me?
Using eval for this is entirely unnecessary. I'd recommend something like this instead:
function rand(ran1, ran2) {
var randomNumb = Math.floor(Math.random()*(ran2 - ran1)) + ran1;
return randomNumb;
}
var rand1 = rand(12, 49);
alert("Your number is: " + rand1);
Notice that in calling the function, the only real difference is in where you place the identifier, rand1.
Further Reading
Functions
return

Why doesn't .attr("src", "/some/path/image.png") work? [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I'm trying to replace the src of an tag with another path. This works perfectly well:
var tempDocId = 'someId';
$('#documents' + that.ticketId).append('<img id="'+tempDocId+'" src="/img/support/pdf_icon.jpg">');
but the following code gives one of those "image not found" icons ():
var tempDocId = 'someId';
$('#documents' + that.ticketId).append('<img id="'+tempDocId+'" src="/img/support/loading.jpg">');
$('#tempDocId').attr("src", "/img/support/pdf_icon.jpg");
Does anybody know what I'm doing wrong here? All tips are welcome!
because you are looking for id="tempDocId", not the one you generated.
$('#tempDocId').attr("src", "/img/support/pdf_icon.jpg");
needs to be
$('#' + tempDocId).attr("src", "/img/support/pdf_icon.jpg");
so you are not replacing the source. My guess is that your loading image is not valid.
Because $('#tempDocId') doesn't exist. tempDocId is a variable, so try:
$('#' + tempDocId).attr('src', '/img/support/pdf_icon.jpg');
var tempDocId = 'doc' + Math.random().toString().substr(2);
var $img = $('<img id="'+tempDocId+'" src="/img/support/loading.jpg">');
$img.appendTo('#documents' + that.ticketId);
$img.attr('src', '/img/support/pdf_icon.jpg');

Categories

Resources