HighDots Forums  

xhtml-strict e nomi form

Javascript (Italian) Il linguaggio JavaScript (it.comp.lang.javascript)


Discuss xhtml-strict e nomi form in the Javascript (Italian) forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
boycottbabies
 
Posts: n/a

Default xhtml-strict e nomi form - 01-29-2005 , 05:30 AM






salve a tutti,
su un documento xhtml-strict 1.0 il validatore html mi segnala questo
notice:

# Line 119, character 12:
<form name="pippo" method="post" action="">
^
Error: there is no attribute name for this element (in this HTML version)

ma a me serve che la form abbia un nome, per poter eseguire dei
controlli sui valori in uno script js.
come posso risolvere?

--
bb

Reply With Quote
  #2  
Old   
Agostino De Matteis
 
Posts: n/a

Default Re: xhtml-strict e nomi form - 01-29-2005 , 05:32 AM






On Sat, 29 Jan 2005 10:30:11 GMT, boycottbabies <bb (AT) epna (DOT) lan> wrote:

Quote:
# Line 119, character 12:
form name="pippo" method="post" action=""
^
Error: there is no attribute name for this element (in this HTML version)
ma a me serve che la form abbia un nome, per poter eseguire dei
controlli sui valori in uno script js.
come posso risolvere?
Non lo usi.
Una possibilita' e' poi di settarne l'id e usare
document.getElementById per accedere alla form.

'bye


Reply With Quote
  #3  
Old   
boycottbabies
 
Posts: n/a

Default Re: xhtml-strict e nomi form - 01-29-2005 , 06:42 AM



Il Sat, 29 Jan 2005 10:32:50 +0000, Agostino De Matteis ha scritto:

Quote:
Non lo usi.
Una possibilita' e' poi di settarne l'id e usare
document.getElementById per accedere alla form.
umh.....
cosi'?

var ettore = document.getElementById('form_id');

per conoscerne ad esempio la action pero' ricevo sempre "undefined":

alert(ettore.action);

ho perso qualche pezzo per strada :-)

--
bb


Reply With Quote
  #4  
Old   
Cristiano Larghi
 
Posts: n/a

Default Re: xhtml-strict e nomi form - 01-29-2005 , 07:08 AM



In data Sat, 29 Jan 2005 11:42:31 GMT, boycottbabies ha scritto:

Quote:
Il Sat, 29 Jan 2005 10:32:50 +0000, Agostino De Matteis ha scritto:

Non lo usi.
Una possibilita' e' poi di settarne l'id e usare
document.getElementById per accedere alla form.

umh.....
cosi'?

var ettore = document.getElementById('form_id');

per conoscerne ad esempio la action pero' ricevo sempre "undefined":

alert(ettore.action);
Vuol dire che non è l'id, quello che hai scritto è corretto...
ipotesi: stai usando per caso asp.net? (cambia id alla form il
bastardone...)
Altra possibilità (se hai una sola form): document.forms[0]

--
"e mai che mi sia venuto in mente
di essere più ubriaco di voi
di essere molto più ubriaco di voi"
F.D.A.


Reply With Quote
  #5  
Old   
boycottbabies
 
Posts: n/a

Default Re: xhtml-strict e nomi form - 01-29-2005 , 08:40 AM



Il Sat, 29 Jan 2005 13:08:15 +0100, Cristiano Larghi ha scritto:

Quote:
Vuol dire che non è l'id, quello che hai scritto è corretto...
errata corrige: ora funziona (qui ho scritto bene, nella pagina ho omesso
un " e non trovava il valore )

Quote:
ipotesi: stai usando per caso asp.net? (cambia id alla form il
bastardone...)
nu nu nu nu.
uso piaccapi'
:^)

Quote:
Altra possibilità (se hai una sola form): document.forms[0]
capito, ma risolto.
grazie.

gia' che ci sono:
in php dichiaro una variabile globale e la riutilizzo dove voglio.
in javascript scrivo pero' se dichiaro ad esempio

var ettore = document.getElementById('form_id');

.....PRIMA che la form sia scritta nell'html, non + va bene?
volevo piazzare alcune variabili globali FUORI dalle funzioni, anziche'
riportarle ogni volta. ma volevo anche evitare di dichiarare le variabili
prima del </body>.
se puede?

--
bb


Reply With Quote
  #6  
Old   
Agostino De Matteis
 
Posts: n/a

Default Re: xhtml-strict e nomi form - 01-29-2005 , 08:47 AM



On Sat, 29 Jan 2005 13:40:54 GMT, boycottbabies <bb (AT) epna (DOT) lan> wrote:

Quote:
in javascript scrivo pero' se dichiaro ad esempio

var ettore = document.getElementById('form_id');
....PRIMA che la form sia scritta nell'html, non + va bene?
volevo piazzare alcune variabili globali FUORI dalle funzioni, anziche'
riportarle ogni volta. ma volevo anche evitare di dichiarare le variabili
prima del </body>.
se puede?
Definiscile in una funzione richiamata da onload del body:

[...]
<head>
[...]
<script type="text/javascript">

var pippo=null;
var topolino=null;

function initVariables(){
pippo=document.getElementById("pippo");
topolino=document.getElementById("topolino");
}
</script>
[...]
</head>
<body onload="initVariables();">
<div id="pippo"></div>
[...]
<form id="topolino">
[...]

'bye


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.