|
Hi I want to create a matrix 'B' like given below while I only have an array 'A'
A=[0 1 2 3 4]
B= [0 1 2 3 4
1 2 3 4 5
2 3 4 5 6
3 4 5 6 7
4 5 6 7 8]
For some reason, these few lines are not working
for (var i=0;i<5;i=i+1){
for (var j=0;j<5;j=j+1){
B[i][j] = A[j]+i;
}
}
Any help or suggestion will be appreciated.
Thanks
|
|
|
|
|
Try this
<script>
A = [0,1,2,3,4 ];
var B = [];
for (var i=0;i<5;i=i+1){
B[i] = [];
for (var j=0;j<5;j=j+1){
B[i][j] = A[j]+i;
}
}
</script>
|
|
|
|
|
Hello
When In a PHP form I fill a field, an onBlur event validates this field and if an error occurs the my_alert function is displayed.
This is the part of the code that runs my_alert function.
$params = array(
'title' => "Warning",
'type' => "error",
'width' => '350px',
'confirmButtonText' => 'OK');
$desc="The field cannot be empty";
my_alert($desc, $params);
So far everything is ok; the my_alert function work fine.
But I wish that, when the alert window is closed, the focus remain on the invalid field and to do this I created a simple javascript function that contains a single line of code and exactly $('#field_id'). Focus () and that should be done immediately after my_alert.
The problem is that it doesn't work: the focus always goes to the next field.
However, if I remove my_alert, this does not happen.
They suggested me to try to pass $params and $desc directly to the javascript focus function and also run my_alert inside it, but I'm in trouble because I don't know javascript well.
Can someone help me?
Thank You and Best Regards
|
|
|
|
|
a Little late but might help other readers - after setting focus to element, just add return false;
This will stop any other code executing and will add focus to your element as required.
|
|
|
|
|
I am creating a p5js project and I want a code that prints the x and y of an ellipse. When I run the code it just shows up as the original x and y of the ellipse. How would I create a code that always changes the string printed on the screen.
|
|
|
|
|
HI all,
can anyone tell me how this MacID,SystemOs, System Version, and computer name? get from the javascript library.
modified 9-May-20 14:39pm.
|
|
|
|
|
|
I would like to add a marker to the map using the form. Can anyone help me? Installing the map works. I want to display markers after entering x and y, and read this data from the table. I have 2 inputs, one for X and the other for Y after clicking "add" I add this data to the table and I have 2 objects, etc ... but only one marker from state.items is displayed on the map, although I have more coordinates in the table.I know that the componentDidMount () method is only run once and here is the problem.Please Help
state={
items:[{
"X": 13.6155611,
"Y": 51.0331258
},
],
}
addItem = (e) => {
e.preventDefault();
const newItem = {
"Y": parseFloat(this.state.X),
"X": parseFloat(this.state.Y),
};
this.setState(prevState => ({
items: [...prevState.items, newItem]
}));
}
componentDidMount() {
const map = new mapboxgl.Map({
container: this.mapContainer,
center: [this.state.lng, this.state.lat],
zoom: this.state.zoom,
});
for (var i = 0; i < this.state.items.length; i++) {
var obj = this.state.items[i];
let myLatlng = new mapboxgl.LngLat(obj.X, obj.Y);
new mapboxgl.Marker()
.setLngLat(myLatlng)
.addTo(map);
}
}
render() {
return (
<div ref={el => this.mapContainer = el} />
<form onSubmit={this.addItem}>
<input
type="number"
value={this.state.X}
onChange={e => this.setState({
X: e.target.value
})}
/>
<input
value={this.state.Y}
onChange={e => this.setState({
Y: e.target.value
})}
/>
</Form>
)}
|
|
|
|
|
is it possible to use this bootstrap table with data tables plugin? can anyone please help me out... as I want to change the view of datatables views. it looks outdated...
|
|
|
|
|
Try asking the people who wrote it.
|
|
|
|
|
Bootstrap is just css so yes, you can apply it.
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.
|
|
|
|
|
Hi,
You could definitely use it. Thanks.
Cheers,
Jin 
|
|
|
|
|
Hi this works, but i would like to add other CountryCodes to include all french speaking countries.
<script language="JavaScript" src="http://www.geoplugin.net/javascript.gp" type="text/javascript"></script>
<script language="JavaScript">
if(geoplugin_countryCode() != 'US'){
if(geoplugin_countryCode() == 'FR'){
location.href = "indexfr.html";
}else{
location.href = "//index.html";
}
}
</script>
if (Type == 2 && (PageCount == 0 || PageCount == '')) {
as if commented out part worked....
the geoplugin generates the country code
Any help welcome
thanks
Peter
|
|
|
|
|
Member 14807823 wrote: as if commented out part worked. What happens when you uncomment it?
|
|
|
|
|
Hi Richard,
The commented part was to illustrate what I was trying to do, it wont work.
so it wont go to the indexfr.html page
Thanks
Peter
|
|
|
|
|
I think your syntax is not correct, try this:
var cc = geoplugin_countryCode();
if (cc == 'FR'|| cc =='CH' || cc =='LU' || cc =='BE' || cc =='LI'){
location.href = "indexfr.html";
}
|
|
|
|
|
Hi Richard,
Yes it was the syntax,
that was the neat and correct solution
Thanks
Peter
|
|
|
|
|
Yes, and I should have spotted it the first time. I will try harder in future. 
|
|
|
|
|
It looks like all you need to do is debug it. I'm not sure what you were wanting us to do.
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.
|
|
|
|
|
Hi Richard
Mainly I wantad to know if that should work, looking around is seems not to be correct..
I dont know how to debug it.
thanks
Peter
|
|
|
|
|
Member 14807823 wrote: I dont know how to debug it. That is the most important skill to have when writing code.
Basically, press F12 in your browser and your browser's developer tools will open. First, check the console to see if you have errors. Then you can click in the line of code you want to test and create a breakpoint.
Too much to go into here, but yes, you'll want to learn to debug.
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.
|
|
|
|
|
Hi ZuroDev,
Yes I know
thanks
Peter
|
|
|
|
|
for what this script? can use in website streaming?
|
|
|
|
|
I'm just getting started and learning through a book and this code won't run on google, was wondering why and what I needed to do to fix it. Thank you in advance.
<pre>
function zeroPad(number, width) {
let string = String(number);
while (string.length < width){
string = "0" + string;
}
return string;
}
function printFarmInventory(cows, chickens, pigs) {
console.log(`${zeroPad(cows, 3)} Cows`);
console.log(`${zeroPad(chickens, 3)} Chickens`);
console.log(`${zeroPad([pigs], 3)} Pigs`);
}
printFarmInventory(7, 16, 3);
|
|
|
|
|
Hi JaHowler,
Maybe you can try this.
function zeroPads(animal, width){
let strNumber = animal.toString(),
len = strNumber.length;
while(len < width){
strNumber += `0${strNumber}`;
len++;
}
return strNumber;
}
function printFarmInventory(cows, chickens, pigs){
console.log(`${zeroPads(cows,3)} Cows`);
console.log(`${zeroPads(chickens, 3)} Chickens`);
console.log(`${zeroPads(pigs, 3)} Pigs`);
}
printFarmInventory(7,16,3);
Output:
"7070707 Cows"
"16016 Chickens"
"3030303 Pigs"
Hope this helps. Thanks.
Cheers,
Jin 
|
|
|
|