1
Good morning !
I’m having a little problem I’m trying to return the value of a radio field printing on the screen to give a return type to the user before making the upload click. I’m currently testing on a script I found, but without much success is returning me Nan, I tried to change from parseint to parseFlot but still unsuccessful.
<form>
<p>Now, with CSS3: </p>
<div class="cc-selector">
<input id="visa" type="radio" name="credit-card" value="20" onfocus="calcularPrimeiro()" />
<label class="drinkcard-cc visa" for="visa"></label>
<input id="mastercard" type="radio" name="credit-card" value="30" onblur="calcularPrimeiro()" />
<label class="drinkcard-cc mastercard"for="mastercard"></label>
</div>
</form>
<div id="resultado"></div>
<script type="text/javascript">
function calcularPrimeiro() {
var n1 = parseFloat(document.getElementsByClassName('credit-card').value, 0);
document.getElementById('resultado').innerHTML = n1;
}
</script>
getElementsByClassName
returns an array of elements. Probably the.value
is returning Undefined.– Francisco
Probably yes, I tried this way now to enter the array and display the value, but still unsuccessfully informs me that the value is without anything declared, Function calculatedFirst() { var n1 = parseFloat(Document.getElementsByClassName('credit-card')); var value = n1[0]. value; Document.getElementById('result'). innerHTML = value; }
– RonaldoM