Non l'ho testato pienamente...

Codice PHP:
<html>
    <
head>
        <
title>Home</title>
        <
script type="text/javascript">
            function 
calc()
            {
                var 
campo;
                var 
divisori;
                var 
numero;
                
campo=document.getElementById("val");
                
divisori=document.getElementById("div");
                
numero=document.getElementById("num");
                
val=campo.value;
                
numero.value="";
                
divisori.value="";
                if(
val>0)
                {
                    
numero.value=val;
                    for (
i=1i<=vali++)
                    {
                        if (
val%i==0)
                        {
                            
divisori.value=divisori.value+" "+i;
                        }
                    }
                }
                else
                {
                    
alert("Valore non valido");
                    
numero.value="Dati non validi";
                    
divisori.value="Dati non validi";
                }
            }
        
</script>
    </head>
    <body>
        <form name="frm">
            <input type="text" name="val" id="val">
            <input type="button" name="run" value="Ok" onClick="return calc()">
            <table width="200" border="1">
                <tr>
                    <td>[b]Valore:[/b]</td>
                    <td><textarea readonly="readonly" name="num" id="num"></textarea></td>
                </tr>
                <tr>
                    <td>[b]Divisori:[/b]</td>
                    <td><textarea readonly="readonly" name="div" id="div"></textarea></td>
                </tr>
            </table>
        </form>
    </body>
</html>