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 5 years ago.
Improve this question
I have a phone number in iOS displayed in a list like :
home: (789)654-1281
I want to remove the home or any other category that will attach with the mobile number.I tried replace() in javascript,but it is not working.Please help.
I am developing hybrid application using kony.
Maybe you can try with something like this :
var number = 'home: (789)654-1281';
number = number.split(': ')[1]; // (789)654-1281
Hope it helps.
var input = "home: (789)654-1281"
var position = input.indexOf(': '); // with space
if (position > 0) {
var output = input.substring(position+2); // + 2 is length of ': '
}
Related
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.
è 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;
}
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(' ');
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 wrote a simple code to fetch a value from text field and so its summation and display it in the third text field
Correct code
var a = document.getElementById("fNo");
var b = document.getElementById("sNo");
var c = document.getElementById("tNo");
var d = document.getElementById("abc");
d.addEventListener("click", function() {
c.value = Number(a.value) + Number(b.value);
});
But when I obtain value in a like this
a = document.getElementById("fNo").value;
It doesnt work.
You will get a string querying the value.
If the input element is of type "number" you can use:
a = document.getElementById('fNo').valueAsNumber;
otherwise you have to convert the string to a number, before you can do the calculation:
a = Number(document.getElementById('fNo').value);
b = // etc.
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 6 years ago.
Improve this question
I have the following code:
function icon(link) {
var iccon = document.createElement('div');
var iccons = document.createElement('td');
iccon.setAttribute('id', 'icon');
icons.appendChild(iccons);
iccon.setAttribute('onclick', 'window.open("' + link + '");');
iccons.appendChild(iccon);
var icons = document.getElementById('icons');
};
The HTML code is here.
Even though it's hard to say what you're trying to achieve with the code, I must say that it's an ordering error: you want to append the newly created items to the #icons element, which you declare at the very end.
Move the last statement to the top of the function and everything will work as expected:
function icon(link) {
var icons = document.getElementById('icons');
var iccon = document.createElement('div');
var iccons = document.createElement('td');
iccon.setAttribute('id', 'icon');
icons.appendChild(iccons);
iccon.setAttribute('onclick', 'window.open("' + link + '");');
iccons.appendChild(iccon);
};
Here's the updated demo: http://codepen.io/gion/pen/NRmgPJ
I must say that you should be more careful about naming. Things get hard to read when they aren't named well.
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