|
As Richard already answered, but it appears another user did not understand, at the end of the salary function add
return d But you really should change the variable names to something that makes sense.
Then, in the point function you can do something simple like this:
var sal = salary();
sal will now have the return value from the salary function and you can use it however you need to.
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.
|
|
|
|
|
I would expect the following two expressions to both evaluate to false:
2 < "12"
"2" < "12"
The second one returns false. That makes sense to me "1" is before "2". In the first case,
we are comparing a number with a string. I would expect the number 1 to be converted to the
string "1" and therefore to evaluate to false. However, it is evaluating to true. What am I missing?
Thanks,
Bob
|
|
|
|
|
BobInNJ wrote: it is evaluating to true
BobInNJ wrote: 2 < "12"
12 is getting converted to int.
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.
|
|
|
|
|
Comparing data of different types may give unexpected results.
When comparing a string with a number, JavaScript will convert the string to a number when doing the comparison.
When comparing two strings, "2" will be greater than "12", because (alphabetically) 1 is less than 2.
|
|
|
|
|
How to delete consumer in kong using java script by nodered?
|
|
|
|
|
Probably by writing some code to handle the delete action.
|
|
|
|
|
What does any of this mean?
It sounds like you're trying to hack something. Bad idea.
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.
|
|
|
|
|
I'm pretty green with Vue & TypeScript and I'm looking to just build some components. I can find lots of pre-rolled things but this is a learning exercise.
I'm struggling to find a decent article or blog post using all these techs. Dose anywhere here have some good up-to-date links to articles or blog posts?
|
|
|
|
|
Quote: I'm looking to just build some components. Then build them, what's stopping you?
Quote: I'm struggling to find a decent article or blog post using all these techs. That is because you have a pretty tight filter applied there. Bootstrap is going to be intrinsic. Try finding for TypeScript and Vue article with Router, Bootstrap can be applied yourself—since you are pretty green in Vue, right?
A quick Google search for "vue router typescript" did yield the following for me,
TypeScript Support — Vue.js
VueTyped - VueRouter Example #2 - Plunker
Adding the bootstrap can be done using their CDN links. You can follow the same approach I used above to find what you are looking for on the Google.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
hi,
I need to open a word file which saved in server in client side(without open/save dialog and not download in client system) and let users to edit it. then save back this file in server again.
I try
Word.ApplicationClass for this, but it open word file in server side.
do you know any component or code in asp.net for doing this??
please answer and help me asap.
best regards.
|
|
|
|
|
Please do not post the same question in multiple forums.
|
|
|
|
|
Greetings again experts,
We have a requirement that when our web app loads, by default, the submit button is disabled:
Here is how I handled that:
<asp:Button runat="server" id="btnSubmit" style="width:120px;padding: 0; border: 0;background-color:#D8D8D8 !important;color: #808080; height:30px;" Text="Generate Report" OnClick="btnSubmit_Click" Enabled="false" />
Then we have six search textbox controls.
When a user enters a value of at least three characters into any of the textboxes, then the submit button is activated.
Here is the script that I am using for that:
script type="text/javascript">
function SetButtonStatus(sender, target) {
var uuid = document.getElementById('<%=suuid.ClientID %>');
var calllist = document.getElementById('<%=caller_list_id.ClientID %>');
var phone = document.getElementById('<%=phonenumber.ClientID %>');
var startdate = document.getElementById('<%=date_start.ClientID %>');
var enddate = document.getElementById('<%=date_end.ClientID %>');
var calltype = document.getElementById('<%=call_type.ClientID %>');
if ((((((sender.value.length >= 3 || uuid.value.length >= 3) || (sender.value.length >= 3 || calllist.value.length >= 3) || (sender.value.length >= 3 || phone.value.length >= 3) || (sender.value.length >= 3 || startdate.value.length >= 3) || (sender.value.length >= 3 || enddate.value.length >= 3) || (sender.value.length >= 3 || calltype.value.length >= 3))))))
document.getElementById(target).disabled = false;
else
document.getElementById(target).disabled = true;
}
</script>
On each of the six search boxes, I call this function like this (just one textbox as an example):
<asp:TextBox id="phonenumber" style="width:150px;" class="form-control" onkeyup="SetButtonStatus(this,'btnSubmit')" runat="server" />
This works good so far.
The issue we are having is that when a user enters value via mouse, then submit button is not activated.
Most users have their autoComplete on such that when a user has entered a value before, next time s/he wishes to use that value again, s/he simply double click the search textbox and selects a pull down value with his/her mouse.
In this case, the button does not get activated.
I am trying to use the following script so submit button can be activated when mouse click on any textbox is detected:
<script type="text/javascript">
$(document).ready(function() {
$("input").keypress(function(e) {
if (e.which == 254) {
$('#btnSubmit').click();
return false;
}
return true;
});
});
</script>
It still does not work as the submit button remains disabled.
I tried keycode===13 and still no love.
Any ideas how I can resolve this?
Thanks a lo in advance
modified 6-Jun-19 12:05pm.
|
|
|
|
|
Assuming you want to test all text inputs in the form, then something like this should work:
$(function(){
var inputSelector = "input:not([type=button]):not([type=submit]):not([type=reset])";
$(document).on("change blur keyup input", inputSelector, function(e){
var validInputs = $(inputSelector).filter(function(index, element) { return element.value.length >= 3; });
document.getElementById("btnSubmit").disabled = validInputs.length === 0;
});
}); Edit fiddle - JSFiddle[^]
.filter() | jQuery API Documentation[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
WOW!
Always very happy to see you pick up my threads because the solution you provide ALWAYS works!
This one didn't disappoint either.
It works perfectly.
Thank you very much Richard.
Really appreciate your help.
|
|
|
|
|
One more thing sir; my sincere apologies.
I know this is not the code but perhaps you can point me in the right direction.
When I click on ANY search input box, without entering or typing in any content, the submit button is activated.
Is there anything in this code below that could be causing this?
<asp:Button runat="server" id="btnSubmit" style="width:120px;padding: 0; border:0;border-width:thin; background-color:#78BE02 !important;color: #333; height:30px; border-style:solid;" Text="Submit" OnClick="btnSubmit_Click" Enabled="false" />
|
|
|
|
|
|
Yea, it is not your code sir.
I have no idea what it is.
I don't have any box with pre-populated values.
When I load the page and click on the Submit button, it is disabled.
It only becomes a problem when I click on any of the boxes and then click Submit without eve typing anything.
Your fiddle sample works great.
I will keep looking at it till I figure out what the issue is.
Again, sir, many thanks for all your help.
|
|
|
|
|
I want count in my textarea product codes.
I have whitelist for product codes so I cant type or write anything else into textarea.
Found bad issue, I can write only static product codes like (first 16 is product code other 6 is how many products it is in list...):
0FAR12345H00123C + 00001P
0FAR54321H00321C + 00001P
0FAR54321H00321C + 00002P
So now I have two problems..
First problem, whitelist universal product codes like this:
0FAR12345H00123C + 00001P
0FAR543H00321C + 00001P
0F321H321C + 00001P
0R31H1C + 001P
Second problem is how to count these product codes under textarea + overall count.
Example under textarea counts:
0FAR12345H00123C: 5
0FAR543H00321C: 2
0F321H321C: 6
0R31H1C: 4
Overall: 17
Javascript:
<pre>
"use strict";
toFile.focus();
var timeoutId;
$('#toFile').on('keypress', function() {
console.log('Textarea Change');
clearTimeout(timeoutId);
timeoutId = setTimeout(function() {
saveToFile();
}, 3000);
});
toFile.addEventListener("keyup", event => {
const data = toFile.value.split("\n");
const result = data.unique();
info.textContent = result.length !== data.length ? "Duplicate removed" : "";
toFile.value = result.join('\n');
});
if (!Array.prototype.unique) {
Object.defineProperty(Array.prototype, "unique", {
configurable: false,
enumerable: false,
writable: false,
value: function() {
const existing = {};
return this.filter(a => existing[a] = !existing[a] ? true : false);
}
});
} else {
throw new Error("Array.prototype.unique already defined.");
}
const CODE = ['Product', 'Codes', 'Here'];
const reg = /^([a-zA-Z0-9]{1,6})$/;
function onInput() {
let values = event.target.value
.split('\n')
.map(v => {
v = v.trim().toUpperCase();
if (v.length <= 16) {
if (CODE[0].substr(0, v.length) != v &&
CODE[1].substr(0, v.length) != v) {
v = v.substr(0, v.length - 1);
}
} else if (!v.substr(16, 22).match(reg)) {
v = v.substr(0, v.length - 1);
}
return v;
}).join('\n');
event.target.value = values;
}
function saveToFile() {
console.log('Saving to the db');
toFile = $('#toFile').val().replace(/\n\r?/g, '<br />');
$.ajax({
url: "test2.php",
type: "POST",
data: {toFile:toFile},
beforeSend: function(xhr) {
$('#status').html('Saving...');
},
success: function(toFile) {
var d = new Date();
$('#status').html('Saved! Last: ' + d.toLocaleTimeString());
},
});
}
$('.form').submit(function(e) {
saveToFile();
e.preventDefault();
})
HTML:
<form class="contact-form" method="post">
<textarea id="toFile" name="toFile" oninput="onInput()"></textarea><br>
<input type="submit" value="Submit">
</form>
<!-- under here I want show count of product codes + overall count -->
<div id="status"></div>
<div id="info"></div
This is how I want count product codes under textarea + overall count:
Image
This shows what you can only type in textarea (Whitelisted product codes):
Image
|
|
|
|
|
Your pretty vague in saying what exactly your having trouble with.
I'm not going to write code for you, but think of part numbers as words, gathering each word and then count the occurrence of each word.
This is done all the time, using words like "apple, orange" so you get a count of "apples" and "oranges"
Perhaps search the internet for a JavaScript example of counting words!
Start again from scratch, and write functions to do the following.
So get all the text in the textarea
Gather and count each occurrence of a word and push the words into an array and increment the counter
Then loop the array, and qualify the words as a part number, remove the ones that don't qualify.
Now you have an array or words and the count.
Then do something with the array of words.
Now go back and write event listeners to trigger your main function.
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
does anyone know of any good interactive tutorials for ReactJS, React Native? It seems there is only like 1 or 2 actually interactive tutorials that exist, the rest are just video tutorials.
|
|
|
|
|
|
Try it, This is the best tutorial site:
https://www.tutorialspoint.com/reactjs/
|
|
|
|
|
Sorry for the belated reply, but the best I could tell you is on Udemy, search for React and the course from instructor Maximilian Shwarzmuller is the best one. It covers all aspect of react, plus redux and redux-saga, along with deployment on a web server and some backend.
|
|
|
|
|
I have coding of a quiz with an array which has questions and options. First time the function is called successfully but when restarting the quiz, the function is not invoked.
This is the code which is not working:
$(document).on('click', '#restart', function() {
showQuestions();
});
The whole coding is:
// Showing questions and options
var x = "";
var i = 0;
function showQuestions() {
document.getElementById('holder').
innerHTML = x;
for (j = 0; j < words[i].options.length; j++) {
if (i < words.length) {
$('#holder').append("<div
id="+words[i].options[j] + "
class='alternatives'>" +
words[i].options[j] + "
</div>");
}
}
if (i < words.length) {
$('#holder').append('<div
id="quest">' +
words[i].question + '</div>');
i++;
}
}
showQuestions();
// Calling function on click of alternatives
$('#holder').on('click',
'.alternatives', function() {
showQuestions();
});
score = 0;
k = 0;
$(document).on('click',
'.alternatives', function() {
let guess = this.id;
if (k < words.length) {
var correct = words[k].answer;
k++;
}
if (guess === correct) {
score++;
}
if (score <= words.length) {
z = score;
document.getElementById('summary').innerHTML = z;
}
if (k >= words.length) {
$('#holder').fadeOut();
$('#restart').fadeIn();
}
});
// Restarting Quiz
$(document).on('click', '#restart', function() {
$(this).fadeOut();
$('#holder').fadeIn();
showQuestions();
});
modified 24-May-19 7:53am.
|
|
|
|
|
You could make your question clearer by using <pre> tags* around the code block, indenting properly, and removing all those redundant blank lines, so it looks like:
$(document).on('click', '#restart', function() {
$(this).fadeOut();
$('#holder').fadeIn();
showQuestions();
});
*or use the code button at the top of the edit window.
|
|
|
|