|
What is the actual text returned from $(t).html() ?
|
|
|
|
|
|
when I try the code I get NaN , most likely because totalRemaining is not defined before it is used in the final expression.
|
|
|
|
|
No totalRemaining is also printing as 5000.00, but when I am trying to add them its retuning NaN
My total function as below:
saveTotalPenalty: function (paramdata, id, indx) {
var m = this.get('model');
let totalRemaining = m.PaymentPlan.TotalAmount;
this.penaltyPerUnit = $(this.boxId).val() / paramdata.Cnt;
this.penaltyPerUnit = this.penaltyPerUnit.toFixed(2);
if ((m.PaymentPlan.ViolationsUniquePenaltyApplied != null) && (m.PaymentPlan.ViolationsUniquePenaltyApplied != 'undefined'))
for (let i = 0; i < m.PaymentPlan.ViolationsUniquePenaltyApplied.length; i++) {
let t = '#' + 'td0' + i;
let a = parseFloat($(t).html().valueOf());
console.log('a');
console.log(a);
totalRemaining = parseFloat(totalRemaining) - a;
console.log('totalRemaining');
console.log(totalRemaining);
}
if ((m.PaymentPlan.ViolationsUniquePenaltyNotApplied != null) && (m.PaymentPlan.ViolationsUniquePenaltyNotApplied != 'undefined'))
for (let i = 0; i < m.PaymentPlan.ViolationsUniquePenaltyNotApplied.length; i++) {
let t = '#' + 'txt' + i;
totalRemaining = totalRemaining - $(t).val();
}
totalRemaining = totalRemaining.toFixed(2);
$('#thTotalRemaining').html(totalRemaining)
if ((paramdata.PenaltyAssessed == null) || (paramdata.PenaltyAssessed == 0) || (paramdata.PenaltyAssessed == 'undefined') || isNaN(paramdata.PenaltyAssessed))
return;
$('#td' + indx).html(this.penaltyPerUnit);
var scope = this;
var data = {
violationPenaltyAdjustment: paramdata,
CaseId: id,
PenaltyAssessed: paramdata.PenaltyAssessed
};
scope.api('Paymentxxxn/AddTotalxxxx').post(data).then(function (response) {
toastr.success("Payment added");
}, function (error) {
Ember.set(payment, "isLoading", false);
toastr.error("Error adding payment plan item");
});
}
modified 18-Feb-21 5:06am.
|
|
|
|
|
I just tried with totalRemaining set to 5000, and the results are correct. There must be something else happening in your code.
|
|
|
|
|
No actually when I am printing as below:
console.log('$(t).html()');
console.log($(t).html());
let a = parseFloat($(t).html());
console.log('a');
console.log(a);
console.log($(t).html()); is printing 1000 but after doing this, it is printing a value as NaN, any help please?
|
|
|
|
|
Sorry, there is nothing more I can do. When I run those few lines of code I get the correct answer. But I cannot reproduce your problem since i do not have all the code.
|
|
|
|
|
So, I am experimenting with recordRTC. I can create the recording and produce a webm file.
Now I need to upload it from the client to the server so I can convert it to mp4.
Any ideas how i can achieve this efficiently?
Thanks,
Ray
|
|
|
|
|
I'm building an application with node.js, and I'm facing a problem connecting javascript or jquery with my node backend APIs. as an example: I can not do import to my controller APIs folder for the javascript or ajax, I tried to do ( type='modle') in config but it make it worse, show me errors for all my (require), so if there's an easy way to connect my scripts with my APIs I will be glad to you guys. even Axios (import axios from 'axios';) did not work with me. and I'm using pug template.
|
|
|
|
|
Hi, I have this line of javascript code inserted in a function...
..
<b>select.options.add(new Option("Standard Floor Base (Base a pavimento Standard)", "SFB"));</b>
..
With this other line of code I access the properties of the "select"....
..
<b>select.classList.add("selectBlock");</b>
..
In the .css...
..
<b>.selectBlock{
font-size: 12px;
width: 290px;
height: 20px;
margin-left: 15px;
}</b>
..
Through a file . css recall the "class" "selectBlock" and change some properties inserted in the "select"...
<b>"Standard Floor Base (Base a pavimento Standard)"</b>
..
I wish I could change only the first part of the text inserted in the "select", exactly this text..
<b>"Standard Floor Base"</b>
..
Is it possible ?... thanks for the help...
|
|
|
|
|
let elements;
let element_text;
let artistname = 'Hans Zimmer';
let spotify_window = window.open('https://open.spotify.com/search/Hans%20Zimmer');
setTimeout(function () {
}, 5000);
elements = spotify_window.document.querySelectorAll('._45331a50e3963ecc26575a06f1fd5292-scss._3957b7dd066dbbba6a311b40a427c59f-scss:not(.good-one)');
alert(elements[0]);
for (let element of elements) {
element_text = element.innerText;
if (element_text == artistname) {
element.click();
break;
}
element.classList.add('good-one');
}
the class name isn't wrong
https://ibb.co/sFTFt81
Also, if I execute the following code in that tab's console, it worked
let elements;
let element_text;
let artistname = 'Hans Zimmer';
elements = document.querySelectorAll('._45331a50e3963ecc26575a06f1fd5292-scss._3957b7dd066dbbba6a311b40a427c59f-scss:not(.good-one)');
alert(elements[0]);
for (let element of elements) {
element_text = element.innerText;
if (element_text == artistname) {
element.click();
break;
}
element.classList.add('good-one');
}
see:
https://ibb.co/PGn9cG4
then it clicked and jumped to the page
https://ibb.co/n6CPmvy
|
|
|
|
|
Javascript in a page from one domain is not allowed to access or modify documents from another domain.
This is a security restriction. Imagine what would happen if code on evilbadguys.com was able to click the "Transfer all my money to the bad guys" button on the yourbank.com site!
There is no way around this, unless you want to try to convince all of your users to severely compromise the security of their browsers.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hello everyone, given that I’ve just started reading HTML code and Javascript language, someone can help me solve this little problem, I’ll give you a generic example, imagine you have a table containing three "checkboxes" A, B and C, the same table contains three "radiobutton" position 1, position 2 and position 3,so for checkbox A we have the possibility to assign only one of the three radiobutton position 1 or 2 or 3 and so also for the other two checkboxes B and C, correspond only one of the three radiobutton, for example, we have selected the checkbox A and the radiobutton corresponding to position 2, I must ensure that, by selecting checkbox B or C, it is no longer possible to select the radiobutton at position 2, because it has already been chosen for checkbox A and so for any other combinations between these specific checkbox and radiobutton, I hope to have explained myself, some help or suggestion thank you.
|
|
|
|
|
I am not sure I understand the question but you can only select one radiobutton in a group. So having selected checkbox A and radiobutton 2, if you then select checkbox B and radiobutton 1, then when the Javascript code processes the checkbox settings, it will only 'see' radiobutton 1 as set.
|
|
|
|
|
Exactly, the javascript function, allows checkbox B to be able to select the radiobattun 1 or 3, since the radiobutton 2 has already been selected in the line of checkbox A, you must also see what happens to the line of checkbox C, if radiobutton 1 or 2 or 3 have been selected, it is the creation of this function that is the problem...
|
|
|
|
|
I still do not fully understand what you are trying to do. You can only have one radiobutton set at any time. As soon as you change it then the previous setting is lost.
|
|
|
|
|
I'm guessing there are three sets of radiobuttons, one for each checkbox.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
|
Probably not the nicest UX, but you can disable the radiobuttons based on the previous element selection.
For example, given the markup:
<ul>
<li>
<label><input type="checkbox" name="a"> A</label>
<ul>
<li><label><input type="radio" name="opta" value="1"> Position 1</label></li>
<li><label><input type="radio" name="opta" value="2"> Position 2</label></li>
<li><label><input type="radio" name="opta" value="3"> Position 3</label></li>
</ul>
</li>
<li>
<label><input type="checkbox" name="b"> B</label>
<ul>
<li><label><input type="radio" name="optb" value="1"> Position 1</label></li>
<li><label><input type="radio" name="optb" value="2"> Position 2</label></li>
<li><label><input type="radio" name="optb" value="3"> Position 3</label></li>
</ul>
</li>
<li>
<label><input type="checkbox" name="a"> C</label>
<ul>
<li><label><input type="radio" name="optc" value="1"> Position 1</label></li>
<li><label><input type="radio" name="optc" value="2"> Position 2</label></li>
<li><label><input type="radio" name="optc" value="3"> Position 3</label></li>
</ul>
</li>
</ul> then the following Javascript will dynamically enable or disable the radiobuttons as you select different options:
let updateOptions = () => document.querySelectorAll("input[type='checkbox']").forEach(chk => {
let li = chk.closest("li");
li.querySelectorAll("input[type='radio']").forEach(rbn => {
if (!chk.checked){
rbn.disabled = true;
rbn.checked = false;
return;
}
let value = rbn.value;
let prevLi = li.previousElementSibling;
while (prevLi !== null){
var prevRbn = prevLi.querySelector(`input[type='radio'][value='${value}']`);
if (prevRbn?.checked){
rbn.disabled = true;
rbn.checked = false;
return;
}
prevLi = prevLi.previousElementSibling;
}
rbn.disabled = false;
});
});
document.querySelectorAll("input[type='checkbox'], input[type='radio']").forEach(el => el.addEventListener("click", updateOptions));
updateOptions(); Demo[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Very much thanks......That’s exactly what I meant..... now I study the parts of Javascript code carefully, again thanks.....
|
|
|
|
|
I want to make this project: https://codepen.io/samuelbeard/pen/Dsdie, to where when you upgrade, it will increment to 0.01 Click Per Second Automatically, instead of 1 click per second. I am pretty sure this has to do with a function, but I am a beginner and cant find anything to change it, and dont have the knowledge. Is there a variable I have to change, or what?
|
|
|
|
|
|
I'm new to JS, hope this will for help. I'll give you a feedback, after completing your Tutorial.
|
|
|
|
|
Sorry, I cannot take the credit for W3Schools.
|
|
|
|
|
I guess I'll leave the feedback there.
|
|
|
|