function num_gen(){
var start_num = document.num_form.min.value;
var end_num = document.num_form.max.value;

var the_code = "";
the_code += '<!-- start random number code -->\n';
the_code += '<!-- random number between ' + start_num + ' and ' + end_num + ' -->\n\n';

if(!document.num_form.is_function.checked){
the_code += '<script language="JavaScript" type="text/javascript">\n'; 
the_code += '<!-- \n';  
the_code += 'var min_num = ' + start_num + '; \n';  
the_code += 'var max_num = ' + end_num + '; \n'; 
the_code += 'var diff = max_num-min_num+1 ; \n'; 
the_code += 'var rnd_number=Math.floor(Math.random()*diff + min_num); \n'; 
the_code += '// --> \n';
the_code += '</script> \n';
}
else
{
the_code += '<script language="JavaScript" type="text/javascript">\n'; 
the_code += '<!-- \n';  
the_code += '// example function call : onClick="get_rnd_num();" \n';
the_code += 'var rnd_number= 0;\n';
the_code += 'function get_rnd_num(){\n';
the_code += 'var min_num = ' + start_num + '; \n';  
the_code += 'var max_num = ' + end_num + '; \n'; 
the_code += 'var diff = max_num-min_num+1 ; \n'; 
the_code += 'rnd_number=Math.floor(Math.random()*diff + min_num); \n'; 
the_code += '}\n';
the_code += '// --> \n';
the_code += '</script> \n';
}

the_code += '\n\n<!-- http://www.webdevtips.com/webdevtips/codegen/random_number.shtml -->\n<!-- end code -->\n';

document.num_form.num_code.value = the_code;
}

function generate_number(){ 
var startnum = document.num_form.min.value;
var endnum = document.num_form.max.value;
startnum-=0;
endnum-=0;
var numdiff = endnum-startnum+1 ;
var msg = "";
for(var i = 1 ; i <= 10 ; i++){
rndnumber=Math.floor(Math.random()*numdiff + startnum);
msg += "number "+ i +" = " + rndnumber + "\n";
}
alert(msg);
}

