How to add var in get value in 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 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

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}`);
});

Add 2 variables inside another variable [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 am trying to create a search variable taking the value of 2 others variables for search results
But I don't manage to get the expected result (title + author). In a sense where the author value is not taking into consideration.
How can I write the following correctly the get both correct values (title + author) in the search variable?
Thank you
let title = document.getElementById('titre-livre').value;
let author = document.getElementById('auteur').value;
let search = title + author;
Remember to separate these values with a space:
let search = [title, author].join(' ');

Javascript parseFloat() change number [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 years ago.
Improve this question
I have a strange problem with JavaScript .
I have text value in a textbox '25000000' when i am
using parsefloat(txt.value), the returned value is 25000 !??
Why is 25000000 changed to 25000 ?
I think there is an alphabet somewhere in your numbers. Check the example below.There is an error in your code.
parseFloat(" 250000000 ") = 250000000
parseFloat("2018#geeksforgeeks") = 2018
parseFloat("geeksforgeeks#2018") = NaN
Thanks for all Responses.
The problem was for ',' in price.
Of course we replace ',' with '' ,but replace method
only change first one like "25,000,000,000"=>"25000,000,000".
I used str.split(',').join('') and problem solve and parsefloat returned correctly.
regards
ali

function that returns first object of a given array [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 7 years ago.
Improve this question
function first(array){
return first(0);
var first = ["gold","brown","green"21,1998];
console.log(first[0]);
trying to create a function that will return the first object of a given array, and am getting an error self[e.data.invoke.func].apply is not a function
not sure what I'm missing?
I tried this and it worked
function firstObject(array){
return array[0];
}
var first = ["Weresquirrel", "Werebear", "Werepanda", "Weremonkey"];
console.log(firstObject(first));

Categories