Код:
<?php session_start();
include('include/configuration.inc.php');
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<script type='text/javascript'>
function other(str) {
if(str.length == 0) {
document.getElementById("container1").style.display="none";
document.getElementById("error").style.display="block";
document.getElementById("ok").style.display="none";
return;
}
else {
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Вашият browsew не поддържа AJAX!");
return;
}
var url="./ajax/check.php?str="+str;
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
}
function GetXmlHttpObject()
{
var xmlHttp=null;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}
function stateChanged()
{
if (xmlHttp.readyState==4)
{
var result = xmlHttp.responseText;
if(result == 0){
document.getElementById("container1").style.display="block";
document.getElementById("error").style.display="none";
document.getElementById("ok").style.display="block";
}
else {
document.getElementById("container1").style.display="none";
document.getElementById("error").style.display="block";
document.getElementById("ok").style.display="none";
}
}
}
function ime(str, a){
if(str != ""){
document.getElementById("error"+a).style.display="none";
document.getElementById("ok"+a).style.display="block";
}
else {
document.getElementById("error"+a).style.display="block";
document.getElementById("ok"+a).style.display="none";
}
}
function all(){
var user = document.getElementById("user").value;
var ime = document.getElementById("ime").value;
var pass = document.getElementById("pass").value;
var pass1 = document.getElementById("pass1").value;
var mail = document.getElementById("mail").value;
if(user != "" && ime != "" && pass != "" && pass != "" && pass1 != "" && mail != ""){
document.getElementById("container").style.display='block';
}
else {
document.getElementById("container").style.display='none';
}
}
</script><title>Регистрация на нов профил</title></head>
<body>
[color=red]<form action="register.php" method="post">[/color]
<table>
<tr><td style='width: 104px;'>User:</td><td><input id='user' type='text' name='user' size='25' onkeyup='other(this.value);all();' value=''></td><td><img id='ok' src='ok.gif' style='display: none;' alt=''><img id='error' src='warning.gif' style='display: none;' alt=''></tr></table>
<div id='container1' style='display: none;'>
<table style='margin-top: -2px;'>
<tr><td style='width: 104px;'>Име:</td><td><input id='ime' type="text" name="ime" size="25" onkeyup='ime(this.value, 1);all();' value=''></td><td><img id='ok1' src='ok.gif' style='display: none;' alt=''><img id='error1' src='warning.gif' style='display: none;' alt=''></td></tr></table>
<table>
<tr><td style='width: 104px;'>Парола:</td><td><input id='pass' type="password" name="pass" size="25" onkeyup='ime(this.value, 2);all();' value=''></td><td><img id='ok2' src='ok.gif' style='display: none;' alt=''><img id='error2' src='warning.gif' style='display: none;' alt=''></td></tr></table>
<table>
<tr><td style='width: 104px;'>Парола отново:</td><td><input id='pass1' type="password" name="pass2" size="25" onkeyup='ime(this.value, 3);all();' value=''></td><td><img id='ok3' src='ok.gif' style='display: none;' alt=''><img id='error3' src='warning.gif' style='display: none;' alt=''></td></tr></table>
<table>
<tr><td style='width: 104px;'>Е-маил:</td><td><input id='mail' type="text" name="mail" size="25" onkeyup='ime(this.value, 4);all();' value=''></td><td><img id='ok4' src='ok.gif' style='display: none;' alt=''><img id='error4' src='warning.gif' style='display: none;' alt=''></td></tr></table>
<table>
<tr><td style='width: 104px;'>Град:</td><td><select name='grad'>
<?php
$query = $MYSQL->query("SELECT * FROM `gradove` order by grad ASC");
while($a = mysql_fetch_array($query)){
$id_grad = $a['id_grad'];
$grad = StripSlashes($a['grad']);
echo "<option value='$ig_grad'>$grad</option>";
}
echo "</select>";
?>
</td></tr></table>
<table>
<tr><td style='width: 104px;'>Пол:</td><td><select name='pol'><option value='мъж'>мъж</option><option value='жена'>жена</option></select></td></tr></table>
<table>
<tr><td style='width: 104px;'>Рожден ден:</td><td>
<?php
echo "Ден: </td><td><select name='den'>";
$i = 1;
while($i <= 31){
if($i < 10){
$a = '0'.$i;
echo "<option value='$a'>$a</option>";
}
else {
echo "<option value='$i'>$i</option>";
}
$i++;
}
echo "</select></td><td>Месец</td><td><select name='mesec'>";
$i = 1;
while($i <= 12){
if($i < 10){
$a = '0'.$i;
echo "<option value='$a'>$a</option>";
}
else {
echo "<option value='$i'>$i</option>";
}
$i++;
}
echo "</select></td><td>Година:</td><td><select name='godina'>";
$yearnow = date("Y");
$old = $yearnow - 7;
$a = 1981;
while($a < $old){
echo "<option value='$a'>$a</option>";
$a++;
}
echo "</select>";
?></td></tr></table>
<table>
<tr><td><div id='container' style='display: block;'><input type="submit" name="submit" value="Добави"></div></td><td></td></tr>
</table></div>
</form>
</body></html>
Защо, когато добавя формата и джава скрипта спира да ми работи - джава скрипта - функциите all(); i ime(); Ако го няма си работи перфект ... Идея ?