|
Thanks for the try. Sorry, i'm using the Materialize template and read the wrong documentation version.
Solution is as follows:
$('#ticket_number').get(0).value = 3;
$('#ticket_number').material_select();
|
|
|
|
|
Hi,
I am new to Javascript but have some experience with C++. Could someone please help me in detail understand what the following lines of code mean?
1. data["count"] = 0 .
2. data.average = 0 .
Thank you!
Scott
|
|
|
|
|
I think this page explains arrays and associative arrays better than I could -> Associative Arrays in JavaScript[^]
“That which can be asserted without evidence, can be dismissed without evidence.”
― Christopher Hitchens
|
|
|
|
|
|
Hi there!
As a junior developer I have hit a dead-end in my search to find the optimal technology for attaching a small CMS to a single webpage so that a user can make edits in real time (only text and background color for now will be enough).
THe only I know stack is basic MEN, and my current webpage is just classic HTML/CSS no SASS, Webpack or any of the fancy stuff. I thought about using Grav, but I know nothing about PhP and thought I should avoid the complexity. I also know that I could achieve something like this with React, but learning React may be an overkill for this?
Can someone recommend an existing app or what I need to study in order to be able to attach a simple CMS to make real-time edits to the HTML and CSS files?
Appreciate any help!
Sak
|
|
|
|
|
I have the following code and if the condition is true it should load a web page but it dont. Help would be appreciated:
Enter your aggretate for your Matric final exam
First name:
Last name:
function myFunction(){
var fname = document.getElementById("fname").value;
if(fname > 40);
window.location.href = "http://www.w3schools.com";
else
alert("Condition xxxxx met")
}
|
|
|
|
|
This is very easy to debug, but only you can do it. We don't have access to your code.
What is the value of fname when the if statement is hit?
Social Media - A platform that makes it easier for the crazies to find each other.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
Member 14916200 wrote:
if(fname > 40); You have a syntax error in your script. If you check your browser's developer console, you should see an error logged telling you that the else is not expected.
That's because you've got an extra semicolon at the end of your if line, which turns your code into:
if (fname > 40) {
}
window.location.href = "...";
else {
alert("...");
} Remove the extra semicolon and your code should work. You should also put braces around the branches:
if (fname > 40) {
window.location.href = "...";
}
else {
alert("...");
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hi there,
As pointed by Richard Deem, there are many syntax errors.
Editing your code as below should work.
function myFunction(){
var fname = document.getElementById("fname").value;
if(fname > 40)
{
window.location.href = "http://www.w3schools.com";
}
else {
alert("Condition xxxxx met");
}
}
|
|
|
|
|
Hi!
I am very new to Java Script and wondering if someone would be able to help me. I have columns F-K (target column numbers 5-10) that are each a multi select drop down field. So, there are multiple answers chosen in these cells. Only one of the columns will be used as a multi select per row. So, if column F has values in it then columns G-K will not have values in it for that row. I am in need of parsing out these multi select answers. So, if on cell F2 10 answers were chosen in this cell then there should be 10 rows of data (one answer per row with the other data copied down). I have the below code so far for column K (#10), but not sure how I get it to do the other columns.
Any help would be very much appreciated! Thank you!
function
zoneparse(range) {
delimiter = "\n"
targetColumn = 10
var output2 = [];
for(var i=0, iLen=range.length; i<ilen; i++)="" {
="" var="" s="range[i][targetColumn].split(delimiter);"
="" for(var="" j="0," jlen="s.length;" j<jlen;="" j++)="" output1="[];" k="0," klen="range[0].length;" k<klen;="" k++)="" if(k="=" targetcolumn)="" output1.push(s[j]);
="" }="" else="" output1.push(range[i][k]);
="" }
="" output2.push(output1);
="" return="" output2;
}<="" pre="">
modified 12-Aug-20 15:17pm.
|
|
|
|
|
I'm working on an artificial intelligence application which draws shapes on images in the canvas. The shapes are drawn by the user.
I implemented zooming, usign this link : https://gist.github.com/dzhang123/2a3a611b3d75a45a3f41
However, once the canvas is zoomed, when user continues to draw, the lines appear with offset. The question is how to translate the
points so the lines to be drawn under the cursor again?
|
|
|
|
|
this is my menu : https://ibb.co/b18Phww
the only missing function in my code is for 'closing' the menu when any li is clicked !
const hamburger = document.getElementsByClassName('hamburger')[0]
const menu = document.getElementsByClassName('menu')[0]
hamburger.addEventListener('click', () => {
menu.classList.toggle('active')
})
<nav class="navbar">
<div class="logo">MY LOGO</div>
<a class="hamburger" >
</a>
<div class="menu">
<ul>
<li><a href="#home">Home</a></li>
<li><a href="#about">About</a></li>
<li><a href="#donate">Donate</a></li>
<li><a href="#download">Download</a></li>
<li><a href="#howto">How</a></li>
<li><a href="#reports">Reports</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</div>
</nav>
Can someone please HELP to fix this problem ?
My hamburger menu works it open & close the menu but when i click on any li, nothing happens !
|
|
|
|
|
|
|
Hi, I am trying to mask a Phone number in a input field, can somebody please help me in this regards. Here is my code for the html (or hbs file)
<label class="control-label">Phone</label>
{{masked-input mask='(999) 999-9999'
value=model.Address.Phone
input-format='regex'
input-filter='\(*[0-9]{3}\) [0-9]{3}-[0-9]{4}'
input-filter-message='Phone number is not valid.'
class='form-control phone masked'
maxlength="14"}}
</div>
And my component definition is as below:
export default () => {
IMS.registerComponent("masked-input", {
tagName: 'input',
attrParams: ['required', 'title', 'name', 'placeholder'],
loaded: false,
prop: Ember.observer(
'required',
'title',
'name',
'placeholder',
'value',
function () {
var scope = this;
$(this.element).val(Ember.get(scope, 'value'));
var stamp = new Date();
if (Ember.get(scope, 'loaded') == true) {
var element = $(this.element);
var attrs = Ember.get(this, 'attrParams');
attrs.forEach(function (attr) {
var value = Ember.get(scope, attr);
if (value == '' | value == null) {
element.removeAttr(attr);
} else {
element.attr(attr, value);
}
})
}
}),
observeMask: Ember.observer('mask', function () {
var scope = this;
$(this.element).inputmask({
mask: Ember.get(scope, 'mask')
});
}),
didInsertElement: function () {
var scope = this;
setTimeout(function () {
var value = Ember.get(scope, 'value');
var element = $(scope.element);
var change = function () { Ember.set(scope, 'value', element.val()); }
element.val(Ember.get(scope, 'value'));
element.attr('type', 'text');
element.change(change);
Ember.set(scope, 'loaded', true);
scope.observeChanges();
element.inputmask({
mask: Ember.get(scope, 'mask')
});
element.attr('input-format', Ember.get(scope, 'input-format'));
element.attr('input-filter', Ember.get(scope, 'input-filter'));
element.attr('input-filter-message', Ember.get(scope, 'input-filter-message'));
}, 250);
}
})
}
Can somebody please help me why is it not working? Thanks in advance.
|
|
|
|
|
My assignment asks for this step that I mentioned in the title, but I have 3 days trying to make it,
I don't know how to do it.here is my code in GitHub:-
https://github.com/HamzaSamiHussein/BusMall/tree/busMall
|
|
|
|
|
Create 2 objects with different fields. Write a code that moves both objects and skincatenates all array fields that will be stored in the variable 'allArrays = [...]'. Calculate the sum of the number elements in the arrays.
* Objects only single level
|
|
|
|
|
|
skincatenating is going to be the difficult bit.
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
There is more than one way to skin a cat.
|
|
|
|
|
Does anyone know a good source on DOM usage?
|
|
|
|
|
|
I'm working on a project in which i'm capturing map screenshot (using dom-to-image library) and sending it to an external api which is returning back some co-ordinates(x,y,w,h) after processing the sent image. These co-ordinates(rectangles) i'm trying to draw on leaflet.
As the captured image size is bigger than width and height of captured area (don't know why), I need to do scaling the co-ordinates.
Now the problem is Leaflet rectangles are not drawing on accurate position which external API is returning.
However, I'm sure that the external API is returning correct co-ordinates (x,y,w,h) with correspond to send image's width & height.
Something wrong i'm doing on scaling coordinates.
Below is the code snippet i'm trying:
domtoimage.toPng(document.querySelector("#map"))
.then(function (dataUrl) {
var boundsOnly = map.getBounds();
let topLeft = boundsOnly.getNorthWest();
let topRight = boundsOnly.getNorthEast();
let bottomLeft = boundsOnly.getSouthWest();
let bottomRight = boundsOnly.getSouthEast();
var currBBOXpoints = { x1y1: map.latLngToLayerPoint(topLeft), x2y2: map.latLngToLayerPoint(topRight), x3y3: map.latLngToLayerPoint(bottomRight), x4y4: map.latLngToLayerPoint(bottomLeft) };
var pW = currBBOXpoints.x2y2.x - currBBOXpoints.x1y1.x;
var pH = currBBOXpoints.x3y3.y - currBBOXpoints.x1y1.y;
currBBOXpoints.pW = pW;
currBBOXpoints.pH = pH;
var i = new Image();
i.onload = function () {
$.ajax({
type: 'post',
url: '/externalapi',
data: JSON.stringify(dataUrl),
contentType: "application/json",
dataType: "json",
success: function (resultData) {
resultData["iW"] = i.width;
resultData["iH"] = i.height;
resultData["currBBOXpoints"] = currBBOXpoints;
drawRects(resultData);
}
});
};
i.src = dataUrl;
});
function drawRects(rectData) {
var scale = Math.max(rectData.currBBOXpoints.pW / rectData['iW'], rectData.currBBOXpoints.pH / rectData['iH']);
var shifted_x = rectData.currBBOXpoints.pW / 2 - rectData['iW'] / 2 * scale;
var shifted_y = rectData.currBBOXpoints.pH / 2 - rectData['iH'] / 2 * scale;
rectData.od.forEach(rc => {
var modifiedX = Number(rc['x']) * scale + shifted_x;
var modifiedY = Number(rc['y']) * scale + shifted_y;
var modifiedW = (modifiedX + rc['w'])
var modifiedH = (modifiedY + rc['h'])
let point3 = map.layerPointToLatLng(L.point(modifiedX, modifiedY));
let point4 = map.layerPointToLatLng(L.point(modifiedW, modifiedH));
var rectBounds = [[point3.lat, point3.lng], [point4.lat, point4.lng]];
var boundingBox = L.rectangle(rectBounds, { color: "yellow", weight: 1, name: "rect", fillOpacity: 0.10 });
map.addLayer(boundingBox);
});
}
|
|
|
|
|
Maybe it has something to do with the monitors screen resolution, dpi, 100% vs 125% view magnification.
When you draw an image is say Illustrator, at 100 x 100, it's 100 pixels x 100 pixels. But when you output that Illustrator file to JPEG or PNG, and then load it up, we think it's still 100 x 100, but it may actually be smaller or larger on the screen.
look at the scale, try a 1 to 1 scale manually.
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
let sum = () => {
a=prompt();
b=prompt();
return a+b;
}
console.log(sum());
I don't understand why the hell concatenate two numbers instead of sum them. Less understand why only a summary is a problem and multiply, extraction, dividing is OK. Can you help me please?
|
|
|
|
|