I have two javascript functions like below which wll count the non-blank lines from textareas.
HTML:
<div id="map-devlist" >
<div class="block-with-text-area">
<div class="input-quest-with-text-area">Enter your device list(one device in one line)</div>
<div class="input-resp-with-text-area"><span><textarea class="textarea" id="devs" name="devs" type="text" onkeyup="devscount();"></textarea></span> </div>
</div>
</div>
<div id="lunidlist" >
<div class="block-with-text-area">
<div class="input-quest-with-text-area">Enter your LUN IDs in Hex(one ID in one line)</div>
<div class="input-resp-with-text-area"><span><textarea class="textarea" id="lunids" name="lunids" type="text" onkeyup="luncount();"></textarea></span> </div>
</div>
</div>
<div id="error1"></div>
Javascript:
function devscount()
{
devcounts = 0;
var lines = $("#devs").val().split("\n");
for (var i = 0; i < lines.length; i++) {
if (lines[i].length > 0) devcounts++;
}
}
function luncount()
{
luncounts = 0;
var lines = $("#lunids").val().split("\n");
for (var i = 0; i < lines.length; i++) {
if (lines[i].length > 0) luncounts++;
}
if(devcounts == luncounts) {
var message ="both counts are matching";
} else {
var message ="Mismatch between values";
document.getElementById('error1').innerHTML=message;
}
}
Now I would like to compare the line count on these two textareas and if they are equal and not equal I need to display a message. But the above script not working for me. When I echo document.getElementById('error1').innerHTML=devscount; and document.getElementById('error1').innerHTML=luncounts; on their corresponding function, it showing the line count perfectly. But I am not able able to compare their values. how to do that ?
if(devcounts() == luncounts())