Can I have a javascript calculator in BBCode?

Get help developing custom BBCodes or request one.
Post Reply
User avatar
nedvrealty
Registered User
Posts: 10
Joined: Tue Oct 15, 2019 9:38 pm

Can I have a javascript calculator in BBCode?

Post by nedvrealty »

Hello, please help me post a calculator in the forum posts. how do i use tags? which? I need to post different calculators on the forum. one of them is like this.

Code: Select all

<script language="JavaScript">
<!--
function IsFloat(strString, err_msg, text_name, calc_type)
{
var strValidChars = "0123456789.";
var strChar;
var blnResult = true;
var Decimal_Count = new Number(0);
for (i = 0; i < strString.length && blnResult == true; i++)
{
strChar = strString.charAt(i);
if (strChar == ".")
{
Decimal_Count = Decimal_Count + 1;
}
if ((strValidChars.indexOf(strChar) == -1) || (Decimal_Count > 1))
{
var err_msg_alert = 'Voer een geldig decimaal nummer in......'
' textbox';
eval('window.document.Calculation_Form.' + text_name + '.select()');
alert(err_msg_alert);
blnResult = false;
this.select;
return blnResult;
}
}

return blnResult;
}


function RectCalc()
{
var blnNoNull = true;
if (window.document.Calculation_Form.R_Length.value == "")
{
window.document.Calculation_Form.R_Length.select();
alert("Bedankt..................");
blnNoNull = false;
}
else
{
if (window.document.Calculation_Form.R_Width.value == "")
{
window.document.Calculation_Form.R_Width.select();
alert("Bedankt.................");
blnNoNull = false;
}
}
if (blnNoNull)
{
var R_Length = new Number(window.document.Calculation_Form.R_Length.value);
var R_Width = new Number(window.document.Calculation_Form.R_Width.value);
var Calc_Rect = new Number(0);
Calc_Rect = (R_Length+R_Width)*2;
Calc_Rect = Calc_Rect*100;
Calc_Rect = Math.ceil(Calc_Rect);
Calc_Rect = Calc_Rect/100;
window.document.Calculation_Form.Calc_Rect.value = Calc_Rect;
}
}
//-->
</script>


<form name="Calculation_Form">
<table align="center">
<tbody><tr><td>Lengte (in eenheden : cm, m…) :</td>
<td><input name="R_Length" onchange="return IsFloat(this.value, 'longueur du rectangle', 'R_Length', 'RectCalc()')" size="10"></td>
</tr>
<tr><td>Breedte (in eenheden : cm, m…) :</td>
<td><input name="R_Width" onchange="return IsFloat(this.value, 'largeur du rectangle', 'R_Width', 'RectCalc()')" size="10"></td>
</tr>
<tr><td></td>
<td><center><input onclick="RectCalc()" value=" = " type="button"></center></td>
</tr>
<tr><td>Omtrek van de rechthoek (in eenheden : cm, m…) :</td>
<td><input name="Calc_Rect" size="10"></td>
</tr>


</tbody></table>
</form>
User avatar
warmweer
Jr. Extension Validator
Posts: 9547
Joined: Fri Jul 04, 2003 6:34 am
Location: Van Allen Bel ... gium
Contact:

Re: Can I have a javascript calculator in BBCode?

Post by warmweer »

nedvrealty wrote: Mon Jan 16, 2023 8:29 pm Hello, please help me post a calculator in the forum posts. how do i use tags? which? I need to post different calculators on the forum. one of them is like this.
...
Have a look at (and there are more search results than that one only)
viewtopic.php?p=15468771.

Having had a quick at the code you posted I suspect you'll need to use divs for the table structure)

Adding Custom BBCodes in phpBB3
Spelling is freeware, which means you can use it for free.
On the other hand, it is not open source, which means you cannot change it or publish it in a modified form.


Time flies like an arrow, but fruit flies like a banana.
Post Reply

Return to “Custom BBCode Development and Requests”