Not Retaining letters in display each keyup (pure javascript) - javascript

I'm making a caesar decoding feature but every time I change the letter the display is not retaining, I need to retain the previous letters in dom, how can I make that happen with most minimal change in my code
var max = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"
var input = document.querySelector('#un');
input.addEventListener("keyup", caesar)
function caesar() {
var userpref = 1
var joe = max.split("")
var text = document.querySelector('#un').value;
var textlet = Array.of(...text);
var num = joe.indexOf(textlet[textlet.length - 1]) + userpref
var fin = joe[num]
var decoded = document.querySelector('#decoded').innerHTML = fin;
}
<input id="un" type="text">
<div id="decoded"></div>
<div id="list"></div>

I updated the snipped to work below:
Just add a + to concatenate the string.
var max = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"
var input = document.querySelector('#un');
input.addEventListener("keyup", caesar)
function caesar() {
var userpref = 1
var joe = max.split("")
var text = document.querySelector('#un').value;
var textlet = Array.of(...text);
var num = joe.indexOf(textlet[textlet.length - 1]) + userpref
var fin = joe[num]
var decoded = document.querySelector('#decoded').innerHTML += fin; // add this plus here!
}
<input id="un" type="text">
<div id="decoded"></div>
<div id="list"></div>

Related

Random image javascript

I am struggling a bit with this random image javascript even though I sense the answer is quite simple. My code generates four letters (images) at a time. How do I get the code to regenerate new letters instead of adding four additional letters (images)?
Here is a Jsfiddle also.
<script>
function getRandomImage() {
//declare an array to store the images
var randomImage = new Array();
//insert the URL of images in array
randomImage[0] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/a.png";
randomImage[1] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/b.png";
randomImage[2] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/c.png";
randomImage[3] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/d.png";
randomImage[4] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/e.png";
randomImage[5] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/f.png";
randomImage[6] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/g.png";
randomImage[7] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/h.png";
randomImage[8] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/i.png";
randomImage[9] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/j.png";
randomImage[10] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/k.png";
randomImage[11] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/l.png";
randomImage[12] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/m.png";
randomImage[13] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/n.png";
randomImage[14] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/o.png";
randomImage[15] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/p.png";
randomImage[16] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/q.png";
randomImage[17] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/r.png";
randomImage[18] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/s.png";
randomImage[19] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/t.png";
randomImage[20] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/u.png";
randomImage[21] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/v.png";
randomImage[22] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/w.png";
randomImage[23] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/x.png";
randomImage[24] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/y.png";
randomImage[25] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/z.png";
//loop to display five randomly chosen images at once
for (let i=0; i< 4; i++) {
//generate a number and provide to the image to generate randomly
var number = Math.floor(Math.random()*randomImage.length);
//print the images generated by a random number
document.getElementById("result").innerHTML += '<img src="'+ randomImage[number] +'" style="height:150px";/>';
}
}
</script>
<body>
<h1> GENERATE YOUR LETTERS... </h1>
<!-- call user-defined getRandomImage function to generate image -->
<center><button onclick = "getRandomImage()" class="btn btn-white btn- animate">Let's Go!</button></center>
<br> <br>
<span id="result" align="center"> </span>
You can add document.getElementById('result').innerHTML = "" before your for loop to clear the result div before adding 4 new items.
You can also reduce your code a lot by using a for loop to generate the image URLs.
var letters = 'abcdefghijklmnopqrstuvwxyz'.split('');
for (let i = 0; i < letters.length; i++) {
randomImage.push(`http://www.englishclass.dk/_themes/englishclass/img/scrabble/${letters[i]}.png`)
}
document.getElementById('result').innerHTML = " " before for loop
<script>
function getRandomImage() {
//declare an array to store the images
var randomImage = new Array();
//insert the URL of images in array
randomImage[0] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/a.png";
randomImage[1] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/b.png";
randomImage[2] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/c.png";
randomImage[3] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/d.png";
randomImage[4] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/e.png";
randomImage[5] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/f.png";
randomImage[6] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/g.png";
randomImage[7] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/h.png";
randomImage[8] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/i.png";
randomImage[9] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/j.png";
randomImage[10] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/k.png";
randomImage[11] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/l.png";
randomImage[12] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/m.png";
randomImage[13] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/n.png";
randomImage[14] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/o.png";
randomImage[15] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/p.png";
randomImage[16] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/q.png";
randomImage[17] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/r.png";
randomImage[18] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/s.png";
randomImage[19] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/t.png";
randomImage[20] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/u.png";
randomImage[21] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/v.png";
randomImage[22] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/w.png";
randomImage[23] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/x.png";
randomImage[24] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/y.png";
randomImage[25] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/z.png";
//loop to display five randomly chosen images at once
document.getElementById("result").innerHTML="";
for (let i=0; i< 4; i++) {
//generate a number and provide to the image to generate randomly
var number = Math.floor(Math.random()*randomImage.length);
//print the images generated by a random number
document.getElementById("result").innerHTML += '<img src="'+ randomImage[number] +'" style="height:150px";/>';
}
}
</script>
<body>
<h1> GENERATE YOUR LETTERS... </h1>
<!-- call user-defined getRandomImage function to generate image -->
<center><button onclick = "getRandomImage()" class="btn btn-white btn- animate">Let's Go!</button></center>
<br> <br>
<span id="result" align="center"> </span>
Add following code at starting of the function definition :
document.getElementById("result").innerHTML = "";
Like this
<script>
function getRandomImage() {
document.getElementById("result").innerHTML = "";
//declare an array to store the images
var randomImage = new Array();
//insert the URL of images in array
randomImage[0] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/a.png";
randomImage[1] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/b.png";
randomImage[2] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/c.png";
randomImage[3] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/d.png";
randomImage[4] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/e.png";
randomImage[5] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/f.png";
randomImage[6] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/g.png";
randomImage[7] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/h.png";
randomImage[8] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/i.png";
randomImage[9] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/j.png";
randomImage[10] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/k.png";
randomImage[11] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/l.png";
randomImage[12] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/m.png";
randomImage[13] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/n.png";
randomImage[14] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/o.png";
randomImage[15] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/p.png";
randomImage[16] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/q.png";
randomImage[17] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/r.png";
randomImage[18] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/s.png";
randomImage[19] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/t.png";
randomImage[20] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/u.png";
randomImage[21] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/v.png";
randomImage[22] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/w.png";
randomImage[23] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/x.png";
randomImage[24] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/y.png";
randomImage[25] = "http://www.englishclass.dk/_themes/englishclass/img/scrabble/z.png";
//loop to display five randomly chosen images at once
for (let i=0; i< 4; i++) {
//generate a number and provide to the image to generate randomly
var number = Math.floor(Math.random()*randomImage.length);
//print the images generated by a random number
document.getElementById("result").innerHTML += '<img src="'+ randomImage[number] +'" style="height:150px";/>';
}
}
</script>
<body>
<h1> GENERATE YOUR LETTERS... </h1>
<!-- call user-defined getRandomImage function to generate image -->
<center><button onclick = "getRandomImage()" class="btn btn-white btn- animate">Let's Go!</button></center>
<br> <br>
<span id="result" align="center"> </span>
As explained in "innerHTML += ..." vs "appendChild(txtNode)" appending new elements by doing innerHTML += '<img />' causes the browser to rebuild the entire container. This may cause performance issues depending on where, when and how often you call it. For the sake of completeness I'm providing the more performant example (a bit more verbose but in general better practice).
This should replace your for loop:
// Clear all childs from the container
const container = document.getElementById("result");
container.childNodes.forEach((child) => child.remove());
for (let i = 0; i < 4; i++) {
const number = Math.floor(Math.random() * randomImage.length);
// Create a new <img /> element and append it to the container
const image = document.createElement("img");
image.src = randomImage[number];
image.style.height = "150px";
container.append(image);
}
You can also get a random letter without splitting a string by using the method given in the top voted answer here. You can then simplify your code as the others have mentioned above to only a few lines.
I've commented the code below.
// Function triggered with onclick event
function getRandomImage() {
// Clear the previous letters
document.getElementById("result").innerHTML = "";
// Loop
for (let i = 0; i < 4; i++) {
// Generate random letter
letter = String.fromCharCode(97 + Math.floor(Math.random() * 26))
// Add image to #result
document.getElementById("result").innerHTML += '<img src="http://www.englishclass.dk/_themes/englishclass/img/scrabble/' + letter + '.png" style="height:150px";/>';
}
}
<h1> GENERATE YOUR LETTERS... </h1>
<center>
<button onclick="getRandomImage()" class class="btn btn-white btn-animate">
Let's Go!
</button>
</center>
<br>
<br>
<span id="result" align="center"> </span>

Form value always read as undefined in Javascript

I'm a new self taught programmer working on my first homework assignment, so I apologize if my naming convention is off. This is the most bizarre thing. No matter how I request the input value, (hoping to pull a number) it always reads as undefined.
Everything works in my javascript function except pulling the input value. I have used forms in the past, and the variables appear to be referencing it fine; I have tried both document.formName.inputName.value, as well as document.getElementById ('input-id').value and it returns undefined. I have renamed my form and variables so many times to see if that was the issue and stI'll nothing. I have tried both input type text and number, and stI'll undefined.
Am I missing something due to how new I am? Please help. Links to github and jsfiddle below.
https://github.com/MissElle/calculator?files=1
https://jsfiddle.net/MissElle/qf7xL8gj/
var dataInput = document.compute.calculate.value;
var element = Number(dataInput);
var numCount = document.getElementById('count');
var numSum = document.getElementById('sum');
var numMean = document.getElementById('mean');
var subCount = [];
var subSum = 0;
var starColors = ['#51fffc', '#ffff96', '#96ffc7', '#f8d8ff', '#d2bfff', '#ffbfbf', '#ffd299', '#ffffff', '#000000'];
function calcData(element) {
if(typeof element === 'number') {
console.log(element);
subCount.push(element);
var starDiv = document.createElement('div');
starDiv.className = 'star';
var starHolder = document.getElementById('star-holder');
starHolder.appendChild(starDiv);
starDiv.style.background = 'radial-gradient(circle, ' + starColors[Math.floor(Math.random() * starColors.length)] + ', transparent, transparent)';
numCount.innerHTML = subCount.length;
for(var i in subCount) {
subSum += subCount[i];
numSum.innerHTML = subSum;
var subMean = subSum/subCount.length;
numMean.innerHTML = subMean;
}
}else {
numCount.innerHTML = 'Not a Number';
console.log(element);
}
subSum = 0;
event.preventDefault();
}
function clearData() {
subCount = [];
subSum = 0;
subMean = 0;
numSum.innerHTML = '';
numMean.innerHTML = '';
numCount.innerHTML = '';
var starHolder = document.getElementById('star-holder');
var starDiv = starHolder.getElementsByClassName('star');
while(starDiv.length > 0) {
starHolder.removeChild(starDiv[0]);
}
}
<form name="compute" onsubmit="calcData()" onReset="clearData()">
<p class="bold">Please enter a number</p>
<input type="number" name="calculate" id="calculation" step="any"><br>
<input type="submit" name="submit" value="star">
<input type="reset" value="nostar" name="clearForm">
<div class="row">
<div class="typevalue"><h4>Count:</h4><h4>Sum:</h4><h4>Mean:</h4></div>
<div class="numbervalue"><p id="count"></p><p id="sum"></p><p id="mean"></p></div>
</div>
</form>
Move your variable declarations inside your function like this:
function calcData(element) {
var dataInput = document.compute.calculate.value;
var element = Number(dataInput);
var numCount = document.getElementById('count');
var numSum = document.getElementById('sum');
var numMean = document.getElementById('mean');
var subCount = [];
var subSum = 0;
var starColors = ['#51fffc', '#ffff96', '#96ffc7', '#f8d8ff', '#d2bfff',
'#ffbfbf', '#ffd299', '#ffffff', '#000000'];
...
If you declare your dataInput outside the function you get no value because that JS code is run after the page loads (before your user types any number in your function).
You have to declare it inside your function that way you get the value of your input when the user clicks on the button.

Why Won't My Hidden Field Populate from JavaScript Function?

I created a JavaScript function that creates a string that I need to use in another form on the website I'm working on. To do this I thought I would just write the value to a hidden field, and then submit it in the HTML form. However, nothing I do will get the value to appear in the field even though the alert will populate.
function customFunc(){
var customD = document.querySelector('input[name = "customD"]:checked').value;
var customL = document.getElementById('Custom_Length').value;
var customW = document.getElementById('Custom_Width').value;
var lowerV = customL * customW;
var maxV1 = Math.ceil(lowerV/100)*100;
var maxV2 = maxV1 - 1;
var lowerB = maxV1 - 100;
var pStyle = document.querySelector('input[name = "pl"]:checked').value;
var itemTest = pStyle +customD+"."+lowerB+"-"+maxV2;
alert(itemTest );
return itemTest ;
document.getElementById('testSku').value = itemTest ;
}
On the HTML side I have this as the hidden field
<input type="text" name="testSku" id="testSku">
The return statement ends a function and returns to the caller. Anything after that in the function is not executed. So the assignment to the input's value is ignored. Put the return statement last.
function customFunc(){
var customD = document.querySelector('input[name = "customD"]:checked').value;
var customL = document.getElementById('Custom_Length').value;
var customW = document.getElementById('Custom_Width').value;
var lowerV = customL * customW;
var maxV1 = Math.ceil(lowerV/100)*100;
var maxV2 = maxV1 - 1;
var lowerB = maxV1 - 100;
var pStyle = document.querySelector('input[name = "pl"]:checked').value;
var itemTest = pStyle +customD+"."+lowerB+"-"+maxV2;
alert(itemTest );
document.getElementById('testSku').value = itemTest ;
return itemTest ;
}

Java script object data for functions

How do I acces some object data in a javascript function? All I want to do is to take some input from the html file and then if the input text is === to one of my objects in javascript i want to acces some data from that object to use within my function.
For example:
I have the html form with 2 text inputs and a button to acces the function. And in the javascript document I have two objecst called bob and susan with the data "bob.age = 25" and "susan.age = 30". So I want a function that calculates bob.age + susan.age. But I want to use the inputs of bob and susan in my form html. So when i have the inputs bob and susan i want the function to do bob.age + susan.age
here is my html form:
<form name="mmForm">
<label for="element1">E1</label>
<input type="text" id="element1">
<label for="element2">E2</label>
<input type="text" id="element2">
<input type="button" value="Calculate" onclick="procesForm_mm()">
<div id="resultfield_mm">Result:</div>
</form>
here my javascript function:
function procesForm_mm() {
var e1 = document.mmForm.element1.value;
var e2 = document.mmForm.element2.value;
result_mm = parseInt(e1) + parseInt(e2);
document.getElementById("resultfield_mm").innerHTML += result_mm;
}
and this is the data i want to acces:
var Fe = new Object();
Fe.denumire = "Fier";
Fe.A = 56;
Fe.Z = 26;
Fe.grupa = "VIIIB";
Fe.perioada = 4;
Try this (a lot of guessing involved):
function procesForm_mm() {
var e1 = document.mmForm.element1.value;
var e2 = document.mmForm.element2.value;
result_mm = parseInt(eval(e1).A) + parseInt(eval(e2).A);
document.getElementById("resultfield_mm").innerHTML += result_mm;
}
var Fe = new Object();
Fe.denumire = "Fier";
Fe.A = 56;
Fe.Z = 26;
Fe.grupa = "VIIIB";
Fe.perioada = 4;
var Co = new Object();
Co.denumire = "Cobalt";
Co.A = 59;
Co.Z = 27;
Co.grupa = "IXB";
Fe.perioada = 4;
See it working here: http://jsfiddle.net/KJdMQ/.
It's important to keep in mind that use of the JS eval function has some disadvantages: https://stackoverflow.com/a/86580/674700.
A better approach would be to keep your JS objects in an array and avoid the use of the eval function:
function procesForm_mm() {
var e1 = document.mmForm.element1.value;
var e2 = document.mmForm.element2.value;
result_mm = parseInt(tabelPeriodic[e1].A) + parseInt(tabelPeriodic[e2].A);
document.getElementById("resultfield_mm").innerHTML += result_mm;
}
var tabelPeriodic = [];
tabelPeriodic["Fe"] = new Object();
tabelPeriodic["Co"] = new Object();
var el = tabelPeriodic["Fe"];
el.denumire = "Fier";
el.A = 56;
el.Z = 26;
el.grupa = "VIIIB";
el.perioada = 4;
el = tabelPeriodic["Co"];
el.denumire = "Cobalt";
el.A = 59;
el.Z = 27;
el.grupa = "IXB";
el.perioada = 4;
(See it working here)
Note: This looks like a chemistry application, I assumed that the form is supposed to add some chemical property values for the chemical elements (i.e. A possibly being the standard atomic weight). The form would take as input the names of the JS objects (Fe and Co).

Assistance needed with Jquery if statement for calculated fields

ow would I write a script that would allow the option of having the user enter a percentage and a dollar amount is calculated or a dollar amount and a percentage is calculated? Currently my form only allows for the entry of a percentage and the dollar amount is calculated, but I need for the user to be able to enter either and have the form automatically calculate the missing element. Here is the code that I am using to calculate the dollar amount:
script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$(".TextBox").hover(function(){
$(this).toggleClass('TextBoxSelected');
},function(){
$(this).toggleClass('TextBoxSelected');
}).change(function(){
calculate();
});
});
function getFldValue(fldValue) {
return isNaN(fldValue) ? 0 : parseFloat(fldValue);
}
function calculate() {
var property_SPrice = getFldValue($('#property_SPrice').val());
var price = getFldValue($('#price').val());
var REO_sale_percentage = getFldValue($('#REO_sale_percentage').val());
var REO_sale_dollars = getFldValue($('#REO_sale_dollars').val());
var REO_sale_bonus_dollars = getFldValue($('#REO_sale_bonus_dollars').val());
var REO_sale_fixed_dollars = getFldValue($('#REO_sale_fixed_dollars').val());
var REO_sale_total_dollars = getFldValue($('#REO_sale_total_dollars').val());
var REO_list_percentage = getFldValue($('#REO_list_percentage').val());
var REO_list_dollars = getFldValue($('#REO_list_dollars').val());
var REO_list_bonus_dollars = getFldValue($('#REO_list_bonus_dollars').val());
var REO_list_fixed_dollars = getFldValue($('#REO_list_fixed_dollars').val());
var REO_list_total_dollars = getFldValue($('#REO_list_total_dollars').val());
var gr_comm_percentage = getFldValue($('#gr_comm_percentage').val());
var gr_comm_dollars = getFldValue($('#gr_comm_dollars').val());
var gr_bonus_dollars = getFldValue($('#gr_bonus_dollars').val());
var gr_fixed_dollars = getFldValue($('#gr_fixed_dollars').val());
var gr_total_dollars = getFldValue($('#gr_total_dollars').val());
$('#price').val(property_SPrice);
$('#gr_comm_percentage').val(REO_list_percentage + REO_sale_percentage);
$('#gr_comm_dollars').val(getFldValue(REO_list_dollars + REO_sale_dollars));
$('#REO_list_dollars').val(getFldValue(REO_list_percentage/100*price));
$('#REO_sale_dollars').val(getFldValue(REO_sale_percentage/100*price));
$('#gr_fixed_dollars').val(getFldValue(REO_list_fixed_dollars + REO_sale_fixed_dollars));
$('#gr_bonus_dollars').val(getFldValue(REO_list_bonus_dollars + REO_sale_bonus_dollars));
$('#gr_total_dollars').val(getFldValue(REO_sale_total_dollars + REO_list_total_dollars));
$('#REO_sale_total_dollars').val(getFldValue(REO_sale_dollars + REO_sale_fixed_dollars + REO_sale_bonus_dollars));
$('#REO_list_total_dollars').val(getFldValue(REO_list_dollars + REO_list_fixed_dollars + REO_list_bonus_dollars));
}
</script>
you could try something like
var fieldvalue= //get the field value
if(fieldvalue.indexOf('%') != -1){
var percentage = parseFloat(fieldvalue.replace('%',''));
//do whatever you need with that value
}

Categories

Resources