include("header.inc.php"); include("lib.php"); include("menuStart.inc.php"); echo ' <TR> <TD colspan="2"><B>Dane Dotyczace ludka </B> </TD> </TR> <TR> <TD class="box_in">Nr ludka</TD> <TD class="box_in_pole"> /*TU MA BYc KRUSOR*/ <INPUT CLASS="input" TYPE="text" VALUE="'.$aRow["NR_SWIAD"].'" NAME="NR_SWIAD" SIZE=7 MAXLENGTH=7 disabled> </TD> </TR> <TR> <TD class="box_in">Nazwisko Imię</TD> <TD class="box_in_pole"> <INPUT CLASS="input" TYPE="text" VALUE="'.$aRow["NAZW_IMIE"].'" NAME="NAZW_IMIE" SIZE=35 MAXLENGTH=35 disabled> </TD> </TR> //info('Aby korzystać musisz być zalogowany !'); echo '<script language="Javascript"> window.alert("Użytkownik niezalogowany !"); </script>'; Loguj(); } include("menuStop.inc.php"); include("footer.inc.php"); ?
i chciałem wykorzystać to:
Listing
<head> </head> <body onload="FormUtil.focusOnFirst()"> <form method="post" action="java script:alert('Formularz zatwierdzony!')"> <!-- pole ukryte --> <input type="hidden" name="hidden1" value="wartość ukryta" /> <!-- pole tekstowe, które powinno stać się elementem aktywnym --> <input type="text" name="NR_SWIAD" value="" /> <!-- przycisk zatwierdzenia --> <input type="submit" value="Zatwierdź formularz" /> </form> </body>
Plik formutil.js
Kod
var FormUtil = new Object;
FormUtil.focusOnFirst = function () {
if (document.forms.length > 0) {
for (var i=0; i < document.forms[0].elements.length; i++) {
var oField = document.forms[0].elements[i];
if (oField.type != "hidden") {
oField.focus();
return;
}
}
}
};
FormUtil.setTextboxes = function() {
var colInputs = document.getElementsByTagName("input");
var colTextAreas = document.getElementsByTagName("textarea");
for (var i=0; i < colInputs.length; i++){
if (colInputs[i].type == "text" || colInputs [i].type == "password") {
colInputs[i].onfocus = function () { this.select(); };
}
}
for (var i=0; i < colTextAreas.length; i++){
colTextAreas[i].onfocus = function () { this.select(); };
}
};
FormUtil.tabForward = function(oTextbox) {
var oForm = oTextbox.form;
// sprawdzenie, czy pole tekstowe nie jest ostatnim polem formularza
if (oForm.elements[oForm.elements.length-1] != oTextbox
&& oTextbox.value.length == oTextbox.maxLength) {
for (var i=0; i < oForm.elements.length; i++) {
if (oForm.elements[i] == oTextbox) {
for(var j=i+1; j < oForm.elements.length; j++) {
if (oForm.elements[j].type != "hidden") {
oForm.elements[j].focus();
return;
}
}
return;
}
}
}
};
FormUtil.focusOnFirst = function () {
if (document.forms.length > 0) {
for (var i=0; i < document.forms[0].elements.length; i++) {
var oField = document.forms[0].elements[i];
if (oField.type != "hidden") {
oField.focus();
return;
}
}
}
};
FormUtil.setTextboxes = function() {
var colInputs = document.getElementsByTagName("input");
var colTextAreas = document.getElementsByTagName("textarea");
for (var i=0; i < colInputs.length; i++){
if (colInputs[i].type == "text" || colInputs [i].type == "password") {
colInputs[i].onfocus = function () { this.select(); };
}
}
for (var i=0; i < colTextAreas.length; i++){
colTextAreas[i].onfocus = function () { this.select(); };
}
};
FormUtil.tabForward = function(oTextbox) {
var oForm = oTextbox.form;
// sprawdzenie, czy pole tekstowe nie jest ostatnim polem formularza
if (oForm.elements[oForm.elements.length-1] != oTextbox
&& oTextbox.value.length == oTextbox.maxLength) {
for (var i=0; i < oForm.elements.length; i++) {
if (oForm.elements[i] == oTextbox) {
for(var j=i+1; j < oForm.elements.length; j++) {
if (oForm.elements[j].type != "hidden") {
oForm.elements[j].focus();
return;
}
}
return;
}
}
}
};
Jak to pogodzić? A może jest inny sposób?
Ciągle wychodzi mi błąd.