Forum Moderators: open
i want to submit the value from the JS function after conveting to hex, to the new window that opens. pls. help
here is my code (if u copy this code and run in browser u can understand my q, i just need to pass the hex value generated to a new window from js function)
<HEAD><TITLE>Unicode 2 converter</TITLE>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<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>
<!--
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 += "0" + num.charCodeAt(i).toString(16).toUpperCase();
return hex;
}
</SCRIPT>
<META content="MSHTML 6.00.2600.0" name=GENERATOR></HEAD>
<BODY>
<P> </P>
<FORM name=blah action=""><B>Arabic Text</B><BR>
<textarea onkeydown=textCounter(this.form.ascii,this.form.remLen); onkeyup=textCounter(this.form.ascii,this.form.remLen); name="ascii" cols="75"></textarea>
<BR>
<INPUT tabIndex=2 readOnly maxLength=3 size=5
value=0 name=remLen>
<BR><BR><B>Hex Value:</B><BR>
<textarea name="hex" cols="75"></textarea>
<BR>
<input name="reset" type=reset onClick="document.getElementById('unicodeHTML').innerHTML = ''" value=Clear>
<INPUT name="button" type=button onclick=encode() value=Submit>
</FORM>
</BODY></HTML>
function convertToHex(num) {
var hex = '';
for (i=0;i<num.length;i++)
hex += "0" + num.charCodeAt(i).toString(16).toUpperCase();
window.location.href="test.htm?"+hex
}
and on the onload on text.htm parse the url to retrieve hex ...
but it could also be done thru popups, imagine your converter page is opened from a mian page in a popup
you could send back hex to main page with
window.opener.document.form.textbox.value=hex ...
the hex code for arabic is 4 characters and the code is just fine for all characters but when i put a space in between 2 words its giving me 3 digit code "020" where as i want 4 digit "0020" for space.
i need this cause for sms in arabic language. sorry for troubling u buddy but i am a new bee to programming.
if u copy the complete code and run in browser and type "this is test"
u get the code
074068069073020069073020074065073074
here 020 is for space, instead for space i need to ad xtra 0 at start i.e 0020
<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> </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>
<BR>
<INPUT tabIndex=2 readOnly maxLength=3 size=5 value=0 name="remLen">
<BR><BR><B>Hex Value:</B><BR>
<textarea name="hex" cols="75" rows="1"></textarea>
<BR>
<input name="reset" type="reset" value=Clear>
<INPUT name="button" type=button onclick=encode() value=Submit>
</FORM>
</BODY>