Forum Moderators: open

Message Too Old, No Replies

Unicode

unicode converter problem

         

designer bhutan

11:33 am on Mar 15, 2005 (gmt 0)

10+ Year Member



hi

i have the following code for converting to hex(unicode) its working fine but its converting the text upon submit i need it to convert as the user goes on typing. just like the counter field that is there on the page.

i think its better if u copy the follwing code and then see it in browser to understand my problem.

thaks in advance

***************************************************
<HEAD><TITLE>Unicode 2 converter</TITLE>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<style>
.titre1 {
font-family: Geneva, Arial, Helvetica, sans-serif;
font-size: 18px;
font-weight: bold;
color: #225E7D;
font-style: italic;
}
</style>
<SCRIPT>
var submitcount;
function reset()
{
submitcount=0;
}

function textCounter(field, countfield) {
countfield.value = field.value.length;
}
function textCountDown(field, countfield, maxlimit) {
if (field.value.length > maxlimit)
field.value = field.value.substring(0, maxlimit);
else
countfield.value = maxlimit - field.value.length;

}
</SCRIPT>
<SCRIPT language=javascript type=text/javascript>
<!--
//Fonction de formatage
function formatage (myvar, longueur)
{
myvar=String(myvar);
while (myvar.length < longueur)
{
myvar = "0"+myvar
}
return myvar;
}

function encode(){
if(document.forms[0].ascii.value!= ''){
var vText = document.forms[0].ascii.value;
document.forms[0].hex.value = convertToHex(vText);
document.forms[0].ascii.focus();
document.forms[0].ascii.blur();
document.forms[0].ascii.select();
}
}
function convertToHex(num) {
var hex = '';
for (i=0;i<num.length;i++)
hex += formatage("0" + num.charCodeAt(i).toString(16).toUpperCase(),4);
return hex;

}

</SCRIPT>
<META content="Microsoft FrontPage 4.0" name=GENERATOR></HEAD>
<BODY>
<P>&nbsp;</P>
<FORM name="blah" action=""><B>Arabic Text</B><BR>
<textarea class="titre1" onkeydown=textCounter(this.form.ascii,this.form.remLen); onkeyup=textCounter(this.form.ascii,this.form.remLen); name="ascii" cols="75" rows="1"></textarea>
&nbsp; <BR>
<INPUT tabIndex=2 readOnly maxLength=3 size=5 value=0 name="remLen">
<BR>
<input name="hex" type="text" value="" size="75">
&nbsp; <BR>
<input name="reset" type="reset" value=Clear>
&nbsp;&nbsp;&nbsp;
<INPUT name="button" type=button onclick=encode() value=Submit>
</FORM>
</BODY>
**************************************************

designer bhutan

4:19 pm on Mar 16, 2005 (gmt 0)

10+ Year Member



hi all of u

pls. help me i am still new to js and badly struck.

designer bhutan

4:21 pm on Mar 16, 2005 (gmt 0)

10+ Year Member



hi all of u

pls. help me i am still new to js and badly struck.