|
Humm..., this is the code for finding the toolbar. My problem is how to ADD the javascript generated button to the toolbar...
The perfect woman: cooks good food and never says no in the middle of the night.
|
|
|
|
|
Yes, I have understood you every time. What you are not getting is that you need to debug the code. I don't have the answer for you but that person took the time to write an article and I trust that it is correct. So, findtoolbar is code to find the toolbar but if it is in the article it's important for a reason. The $print part looks like it is the actual button. I believe, as I have stated, that findtoolbar is an existing Microsoft function that gets called already. The article, I believe, is hoping that this new findtoolbar function will get called instead of the built-in one and this new one works in chrome and firefox.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
I’m learning nodeJS.
I don’t know what is the purpose of
callback argument in
module.exports . It pretty much look like
return and
console.log
here is my code
var request = require('request');
module.exports = function(location,callback) {
var encodedUrl = encodeURIComponent(location);
var url = "http://api.openweathermap.org/data/2.5/weather?q="+encodedUrl+"&APPID=575991c6b55a139d32139652d78bc8b8&units=metric";
if(!location) {
callback("No location provided");
} else {
callback('location is '+location);
}
request({
url: url,
json: true
}, function (error,response, body) {
if(error) {
callback('Unable To Fetch Weather');
} else {
callback("Current Temperature in "+body.name+" "+body.main.temp + '\xB0!!!');
}
});
};
|
|
|
|
|
The purpose of callback is to invoke appropriate callback method based on error and success condition after calling third party api.
rahul
|
|
|
|
|
wanna learn how to create your own site and dashboard where people can contact you and get details and know about you
|
|
|
|
|
|
I am developing a web upload page in asp.net. Here I am providing interface to select different files as in thisfig.
It works properly. Here I have provided option to remove wrong file selections before uploading. But if I click on second or 3rd button all the selected images(1,2,3) gets deleted from page instead of respective selection.
This is the function I have given to button click,
function attachmentremove()
{
var browse = document.getElementById("FileUpload");
var newbrowse = browse.cloneNode(false);
browse.parentNode.replaceChild(newbrowse, browse);
}
I have given 3 different functions for different button click.
How to solve this error ?
|
|
|
|
|
I am trying to change the webpage background based on the user preferences, they have at the moment 5 background images to choose from.
When they click the background image that they want, the code-behind saves the image to a user preferences table in SQL and also updates the users cookie, when the master page is loaded a call to the cookie is made to get the image.
Public MyBg as string
MyBg = "css/image/" & Request.Cookies("tmr")("bgi")
In Code-Behind Master Page, and On the page I have
<pre lang="Javascript"><script type="text/javascript">
window.onload = function () {
function load() {
$('#content').css('background', '#000 url(' + <%=MyBg %> + ') center');
}
}
</script>
If I view the page source code on a rendered page I can see
<script type="text/javascript">
window.onload = function () {
function load() {
$('#content').css('background', '#000 url(' + css/image/ecb.jpg + ') center');
}
}
</script>
All looks good apart from the fact NO image is in the background, can anyone help with this?
|
|
|
|
|
Well, it doesn't look good. If you check the error console, you'll see an "unterminated string literal" error, because your background path is outside of the Javascript string.
Your onload event handler also declares a nested function to set the background, but never calls it.
Change your code to:
window.onload = function() {
$('#content').css('background', '#000 url(\'<%=MyBg %>\') center');
};
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
at last it is working, thank-you so much, only spent 4 hours on this simple task.
|
|
|
|
|
Hi, I have been given the task of teaching JS to non-techies.
I think Sublime 3 looks good.
I think JSHint / Gutter linter looks good.
Q1. Are these products easy to use by newbies?
Q2. Does anyone know how these products (Sublime and JSHint) can be installed on a usb drive so that it is truly portable and can be mode from pc to pc or classroom to classroom or home?
Students don't have the ability to install software in campus computers.
Much thanks,
David
|
|
|
|
|
|
A1. No. It is even more interesting, how a text editor and a style-cop library related to teaching JavaScript to non-tech person!!! Teach them basics of JS, based on some JS tutorial...If you need personal code space use some online tool, like TutorailsPoint's CodingGround or jsFiddle...
A2. It very depends on security policy on the campus, but theoretically, you can load anything from a disk-on-key drive...
Skipper: We'll fix it.
Alex: Fix it? How you gonna fix this?
Skipper: Grit, spit and a whole lotta duct tape.
|
|
|
|
|
I've been working on this for a couple of hours. I have a confirm, and it always returns false no matter which button you click.
I tried it on Windows Firefox, Edge, Chrome, and IOS Safari, Chrome and it works fine.
I ran some test to see if the code is running to the end, but it's not. In VS2015 there are no errors, edge using F12 no errors.
I'm scratching my head on this one.
var _confirm = confirm('Are you sure you want to delete the section ' + _name);
alert(_confirm);
if (confirm) {
}
|
|
|
|
|
If that is your actual code and not just a copy/paste error, your if statement is not testing the _confirm variable (but I would expect that to be true all the time because confirm is a function).
|
|
|
|
|
 It's not the actual code, just an example. I did some searching before my post and tested some other thoughts. Some thoughts talked about it being an async function and the code just ran through.
The code is pretty large in size, but I will post it. It's all on one page or external script file.
I did test it compressed and uncompressed thinking that my gulp script that compresses the script for production use was making an error of some sort.
The only thing that I can think of is a bug in Firefox, but I doubt that!
$(document).ready(function () {
$("#sectionDelete").click(function () {
$("#sectionForm").validate({
ignore: "",
errorClass: 'input-validation-error',
rules: {
Section_DeptID: {
required: true,
minLength: 1
},
Section_SectiontID: {
required: true,
minLength: 1
},
Section_Name: {
required: true,
minLength: 2
},
Section_Desc: {
required: true,
minLength: 2
}
},
messages: {
Section_Name: 'Section requires a name',
Section_Desc: 'Section requires a description'
},
highlight: function (element, errorClass) {
$(element).addClass(errorClass);
},
unhighlight: function (element, errorClass) {
$(element).removeClass(errorClass);
},
success: function (result) {
if (result === "1") {
return true;
}
else {
return false;
}
}
});
if ($("#sectionForm").valid()) {
var deptID = parseInt($("#Section_DeptID").val()),
sectionID = parseInt($("#Section_SectionID").val());
if ((isNaN(deptID) || deptID === -1) && (isNaN(_sectionID) || sectionID === -1)) {
$("#selectSection").text('You must select a section first!').addClass('text-danger');
}
else {
sectionDelete();
}
}<br />
});
});
This is the function that is called from above.
function sectionDelete() {
var $e_Section_DeptID = $("#Section_DeptID"),
$e_Section_SectionID = $("#Section_SectionID"),
$e_Section_Name = $("#Section_Name"),
$e_sContainer = $("#Section_Container"),
_deptID = parseInt($e_Section_DeptID.val()),
_sectionID = parseInt($e_Section_SectionID.val()),
_name = $e_Section_Name.val(),
_confirm = confirm('Are you sure you want to delete the section ' + _name);
if (_confirm === true) {
$e_sContainer.empty().append(pWait);
$.ajax({
type: "POST",
cache: true,
dataType: "json",
url: '/Ajax/json_section_delete',
data: { DeptID: _deptID, SectionID: _sectionID },
error: function (response) {
debugger;
thisObj.toggleClass('active');
alert("http code: " + response.status + " Error: json_sections_load - data: " + response);
},
success: function (data) {
if (data.length === 0) {
$e_sContainer.empty().append(pNull);
}
else {
var sections = '<ul class="nav nav-pills nav-justified">';
for (var x = 0; x < data.length; x++) {
if (data[x].Enabled === true) {
sections += '<li class="col-xs-3" style="width: 33%; float: left; margin: 1% 0;"><button class="section btn btn-success btn-sm" title="' + data[x].Description + '" data-val="1" onclick="sectionRecordLoad(this, ' + data[x].SectionID + '); return false;" type="button">' + data[x].Name + '</button></li>';
}
else {
sections += '<li class="col-xs-3" style="width: 33%; float: left; margin: 1% 0;"><button class="section btn btn-warning btn-sm" title="' + data[x].Description + '" data-val="0" onclick="sectionRecordLoad(this, ' + data[x].SectionID + '); return false;" type="button">' + data[x].Name + '</button></li>';
}
}
sections += '</ul>';
$e_sContainer.empty().append(sections);
}
}
});
}
}
|
|
|
|
|
|
I was using another web app I wrote and went to delete a record, and the same thing happened. Thanks for double checking that, wasted a couple of hours on it.
Thanks!
|
|
|
|
|
I wrote this manual validator for a SPA form.
It's works, just cosmetically wrong.
So the validator creates a label element under the textbox, and assigns the textbox class to the label instead of the class for the label.
I tried removing the class and adding the correct one, but I just can't seem to hookup the element.
$(element.form).find("label[for=" + element.id + "]")
Dynamic Label created by JQuery.Validate, it should be field-validation-error so that its red text on on the inherited background color white. But currently it's a red background and border with black text.
<label for="Section_Desc" class="input-validation-error" id="Section_Desc-error">Section requires a description</label>
This is my validation rule that I wrote.
var validator = $("#sectionForm").validate({
errorClass: 'input-validation-error',
rules: {
Section_Name: {
required: true,
minLength: 2
},
Section_Desc: {
required: true,
minLength: 2
}
},
messages: {
Section_Name: 'Section requires a name',
Section_Desc: 'Section requires a description'
},
highlight: function (element, errorClass) {
$(element).addClass(errorClass);
$(element.form).find("label[for=" + element.id + "]")
.removeClass(errorClass)
.addClass('field-validation-error');
},
unhighlight: function (element, errorClass) {
$(element).removeClass(errorClass);
$(element.form).find("label[for=" + element.id + "]")
.addClass('field-validation-valid')
.removeClass('field-validation-error');
}
});
|
|
|
|
|
I had to add the microsoft unobtrusive validator
|
|
|
|
|
Several times, I have had to implement multidimensional array constructs using JavaScript but encountered difficulties. Since then, I'd been using other languages to
achieve this purpose. But recently, I was able to devise a way around it which I would like to share:
//Snippet
var k = 0;
var rows = new Array(4);
var cols = new Array(4);
var multiArray = new Array(rows, cols);
//initialization of values
for(var i=0; i<4; i++){
for(var j=0; j<4; j++){
multiArray[i][j] = ++k;
}
}
//prints out values into HTML body in a web browser
for(var i=0; i<4; i++){
for(var j=0; j<4; j++){
document.writeln('
'+multiArray[i][j]);
}
}
I believe the code snippet is easy to comprehend and use. A simple guide:
The 'cells' are initialized with values using loop construct. And in the second loop block the values will be displayed into the body of a webpage.
But it's interesting to know that JavaScript doesn't yet have an inherit way of programming multidimensional array. This
implementation and any other that you might come across won't support many of the properties and methods like implementation in strong type languages (C++, C#, etc).
Hopefully, there would be a library that will support all the features of multidimensional array implementation in JavaScript.
I'd like to attend to your questions, if you've any.
modified 22-Jun-16 8:31am.
|
|
|
|
|
Maybe because you misspelled "success" as "succsess" ?
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
|
Hi All,
I am working on computing Xor operation, but i could not exactly compute the proper result. Please help me to find a solution.
If we "true" and "false", how to compute XOR operation to get the final result?
I have tried like:
result = s1 ^ s2; // here s1= "true", s2= "false"
Regards,
Amal Raj
|
|
|
|
|
What do you mean by 'compute'? XOR is a standard operation and will return the defined result in all cases; i.e. TRUE when inputs are different, and FALSE when they are the same.
|
|
|
|
|