here if i click the Generate Employee Id button it should generate the random number in input textfield and then that button should hide after generate the id. how to do that? but, i can automatically generate the random number in input textfiled without the button. that code is below i'm posting. i want to use button here.. any help...??

<td><input type="text" name="emp" readonly="readonly" value="" /></td>
<td><input type="button" value="Generate Employee Id" onclick="" /></td>

this is the code for generate auto random number in input textfield without button..

<input type="text" name="emp" readonly="readonly" value="<?php 
    function gen_random_string($length=6)
        $chars ="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890";
        $final_rand ='';
        for($i=0;$i<$length; $i++)
            $final_rand .= $chars[ rand(0,strlen($chars)-1)];
        return $final_rand;
    echo gen_random_string()."\n"; //generates a string 
    ?>" />

This should work:

function randomStringToInput(clicked_element)
    var self = $(clicked_element);
    var random_string = generateRandomString(10);

function generateRandomString(string_length)
    var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
    var string = '';

    for(var i = 0; i <= string_length; i++)
        var rand = Math.round(Math.random() * (characters.length - 1));
        var character = characters.substr(rand, 1);
        string = string + character;

    return string;

<td><input type="text" name="emp" readonly="readonly" value=""></td>
<td><input type="button" value="Generate Employee Id" onclick="randomStringToInput(this)"></td>

What it does is it uses Javascript to generate a random string of X length, and then sets the value of input[name=emp] to be that random string.