Jump to content
Henco

Number to Hexadecimal converter

Recommended Posts

I am trying to create an html block with custom JS code that converts my Record Count Field into a hexadecimal value.

Eg. RecordCount = 1000, then  convert to Hex = 3E8.

I need this value to be displayed. 

Can someone please assist me with some code?

Share this post


Link to post
Share on other sites

If you are on a submission DataPage and you have an input for the number with the field name: "NumberValue" and another field where you want to store "Hex" you can use the code below in the footer


<div id=d1></div>
<script language='JavaScript' type='text/JavaScript'>
<!--

document.getElementsByName("Submit")[0].onmouseover = function (){

var n1=document.getElementById("InsertRecordNumberValue").value;
if(isNaN(n1)){
document.getElementById("d1").innerHTML=document.getElementById('t1').value + " is not a number ";
}else{
n1=parseInt(n1);

var h = document.getElementById("InsertRecordHex").value =n1.toString(16);
// Change the toString(16) to toString(8) or toString(2) get Octal and binary conversion
}

}
//-->
</script>

on Details or update page as long as the form element is not "display only" and "cascading" you can change "InsertRecord" to "EditRecord" in the code above. 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...