Add random code with javascript in input
<p>I have two input fields. First is a field where user writes in any text (ex. product name) and another one is the field called "Alias" of the product name, it is creadet automatically in real time when user writes the product name. it is done with javascript, so my question is how to add some javascript code in order to add some random code like (aSDAS55AD546) AT THE END OF EACH ALIAS. </p>

<p>Here is the code:</p>

<p>the input fields:</p>

<p>product name:</p>

<pre><code>&lt;input id="asd" onKeyUp="keypress()" name="editname_&lt;? echo $languages[$i][0]; ?&gt;[&lt;? echo $key; ?&gt;]" type="text" value="&lt;? echo $item['name'][$languages[$i][0]];?&gt;" /&gt;
</code></pre>

<p>Alias field:</p>

<pre><code>&lt;input name="editalias[&lt;? echo $key; ?&gt;]" id="sdf" onFocus="javascript:stripspaces(this)" readonly="readonly" type="text" value="&lt;? echo $item['alias'];?&gt;" /&gt;
</code></pre>

<p>and this is the javascript code:</p>

<pre><code>&lt;script type="text/javascript"&gt; 

function keypress()
{ 
var txt=document.getElementById('asd').value;
str1 = " \",'!=:;\йцукенгшщзхъжэдлорпавыфячсмитьбюЙЦУКЕНГШЩЗХЪЭЖДЛОРПАВЫФЯЧСМИТЬБЮăîșțĂÎȘȚ"; 
str2 = "00000000icukengsszhijedlorpavifacsmitibuICUKENGSSZHIEJDLORPAVIFACSMITIBUaistAIST";
for(i=0; i&lt;str1.length; i++) 
   { 
 txt = txt.replace(new RegExp(str1[i],"g"), str2[i]); 
} 

document.getElementById('sdf').value=txt;
} 
&lt;/script&gt; 


&lt;script type="text/javascript"&gt;
$().ready(function(){
    $("input#asd").keyup(removeextra).blur(removeextra);
});
function removeextra() {
    var initVal = $(this).val();
    outputVal = initVal.replace(/[^0-9a-zA-Zа-яА-Я\s'",!ăîșțĂÎȘȚ]/g,"");       
    if (initVal != outputVal) {
        $(this).val(outputVal);
    }
};
&lt;/script&gt;
</code></pre>

<p>This javascript is saving me alot of time. My website is for Russia, and it also translates from russian to english letters.</p>

<p>So please how can i make a random code for alias?</p>

<p>Thanks in advance!</p>
