arithmetic operation using JavaScript [closed] - javascript

Closed. This question needs debugging details. It is not currently accepting answers.
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.
Closed 3 years ago.
Improve this question
i am trying to perform addition in javascript. below is my code :
function myfunc(size){
var m = parseInt(size)+5;
alert(m );
When i use 'alert',it works perfectly.. but i want to use sweet alert and it is not display anything via sweet alert. when i do:
function myfunc(size){
sweetAlert(size );
it does display the size using the code above. the problem is, it doesn't work when i try to perform the addition. why is it so?

try something like this
import swal from "sweetalert";
function myfunc(size) {
var m = parseInt(size) + 5;
swal(String(m));
}
myfunc("6");

Related

Javascript Couldn't Pickup InnerHTML [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
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.
Closed 2 months ago.
Improve this question
Here is my page element:
Then I tried to pick up the value demo#.... from the element class name user-name using these code:
var x = document.getElementsByClassName("user-name")[0].innerHTML;
console.log("x is: " + x);
It would return me:
x is:
Any idea how to fix this?
Looking at your approach, the code innerHTML should have worked, there might be some other issue which might be occurring.
Like 1) there might be other tag with same class name, 2) the username value might not be updated when you called the function.

Using regex with str.split JavaScript and parsing them separately [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
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.
Closed 4 months ago.
Improve this question
I want to be able to separate this one by one
Sephora26:theactor424#gmail.com:shpk335$A:what’s your name?:actor Dawg4075:dawg648#yahoo.com:Thoiland3:what’s your favorite pet?:cat Thrive65:evergreen45#hotmail.com:gcap1078!:what’s your favorite artist:Ed sheeran
I tried using JavaScript str.split() but it only parsed the first character (sephora26). What I want is to be able to parse the email and password out of it
Does it look like something you're looking for?
const strings = `Sephora26:theactor424#gmail.com:shpk335$A:what’s your name?:actor
Dawg4075:dawg648#yahoo.com:Thoiland3:what’s your favorite pet?:cat
hrive65:evergreen45#hotmail.com:gcap1078!:what’s your favorite artist:Ed sheeran`
const lines = strings.split('\n');
lines.forEach((line) => {
[name,email,password,question,answer] = line.split(":");
console.log(`name=${name}, email=${email}, password=${password}`);
});

Special Character codes to Normal symbol - JavaScript [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
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.
Closed 2 years ago.
Improve this question
I have a dropdown showing list of languages,
Now, some of these languages contains special HTML characters, but I want to show the real values of those characters.
Like.
&egrave should be replaced with è
How to do this using Javascript ?
Thanks in advance !!
One way to do this:
const decodeHtml = (html) => {
const t = document.createElement("textarea");
t.innerHTML = html;
return t.value;
}

write c# code in JavaScript function in Razor [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
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.
Closed 3 years ago.
Improve this question
my question is very short want to this :
$(document).on('click', '.ee', function(){
$('.b').val("#Model.Result.GoingDate.AddDays(-1).ToString()");
#{Model.Result.GoingDate = Model.Result.GoingDate.AddDays(-1); }
});
but it's not working
is there any other way to that?
I know I can use javascript date
but don't know how
you cant do that with razor instead
use this method I kind of know what you need
you want to go to next day and update your text in HTML
$(document).on('click', '.ee', function () {
var currentDate = $('.txt-date').val();
var gdate = new Date(currentDate);
gdate.setDate(gdate.getDate() + 1);
$('.b').val(goingDate.toISOString().substring(0, 10));
});

How to add var in get value in JavaScript? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
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.
Closed 8 years ago.
Improve this question
How to add var in get value in JavaScript ?
I have 2 var
var page = $('#demoajax').val();
var name = $("#users").val();
This is mym old code
data:"server=Windows&actionfunction=showData&page="+page,
I want to add var name and value now=date to this line how can I do that ?
First I try this
data:"username="+name+"&server=Windows&actionfunction=showData&page="+page+"&now=date",
But not work.
You appear to have inserted your changes in the middle of the query string. Try this instead.
data:"server=Windows&username="+name+"&actionfunction=showData&page="+page+"&now=date",
Why do you have data:"username="+name+"&server=Windows&actionfunction=showData&page="+page+"&date=now",
switch date and now
Also lose the comma at end if not needed

Categories