PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : [XHTML 1.0 Transitional] Was soll das? - onClick



nul
20-03-2006, 13:33
Was ist mit dem onClick-Attribut?
Hab folgenden Code:

<table border="1">
<tr>

<td colspan="3">
<div class="titleRow">titleText</div>
</td>
</tr>
<tr>
<td class="row1">
Test Page&nbsp;</td>
<td class="row1" width="2%">
<div align="center"><form action="connect.php" method="post">
<img alt="" onClick="" src="include/theme/default/images/inactive.png" />
<input name="cnn_type" type="hidden" value="0" />
<input name="cnn_usr" type="hidden" value="1" />
<input name="cnn_pg" type="hidden" value="3" />
</form></div></td>
<td class="row1" width="2%">

<div align="center"><form action="connect.php" method="post">
<img alt="" onClick="" src="include/theme/default/images/inactive.png" />
<input name="cnn_type" type="hidden" value="0" />
<input name="cnn_usr" type="hidden" value="1" />
<input name="cnn_pg" type="hidden" value="3" />
</form></div></td>
</tr>
<tr>
<td class="row1">
test2&nbsp;</td>
<td class="row1" width="2%">
<div align="center"><form action="connect.php" method="post">
<img alt="" onClick="" src="include/theme/default/images/inactive.png" />
<input name="cnn_type" type="hidden" value="0" />
<input name="cnn_usr" type="hidden" value="1" />
<input name="cnn_pg" type="hidden" value="2" />

</form></div></td>
<td class="row1" width="2%">
<div align="center"><form action="connect.php" method="post">
<img alt="" onClick="" src="include/theme/default/images/inactive.png" />
<input name="cnn_type" type="hidden" value="0" />
<input name="cnn_usr" type="hidden" value="1" />
<input name="cnn_pg" type="hidden" value="2" />
</form></div></td>
</tr>
</table>
Das onClick-Attribute bei den Bilder brauche ich um das Formular zu uebermitteln.
Gibt es onClick in XHTML nicht - und wenn ja, wie soll das sonst gehn?

mfg

Turbohummel
20-03-2006, 17:28
<input type="image">
Allerdings funzt onclick trotzdem, ich würde nur auch ein event auslösen, wenn drauf geklickt wird ;)

undefined
20-03-2006, 18:46
Leere Attributes sind in XHTML nicht erlaubt.

nul
20-03-2006, 19:06
Das mit den leeren Attributen ist schon war, der Validator meckert aber immer noch!
Der Text hat sich jetzt ein wenig geaendert:

<table border="1">
<tr>

<td colspan="3">
<div class="titleRow">Connect User &amp; Project</div>
</td>
</tr>
<tr>
<td class="row1">
<span class="tableItemTitle">Test Page</span></td>
<td class="row1" width="2%">
<div align="center"><form action="connect.php" id="form_index_0" method="post">
<img alt="" onClick="document.getElementById( 'form_index_0').submit();" src="include/theme/default/images/active.png" />
<input name="usr_id" type="hidden" value="10" />
<input name="cnn_pg" type="hidden" value="3" />
<input name="todo" type="hidden" value="disable" />

<input name="field" type="hidden" value="cnn_index" />
</form></div></td>
<td class="row1" width="2%">
<div align="center"><form action="connect.php" id="form_admin_1" method="post">
<img alt="" onClick="document.getElementById( 'form_admin_1').submit();" src="include/theme/default/images/active.png" />
<input name="usr_id" type="hidden" value="10" />
<input name="cnn_pg" type="hidden" value="3" />
<input name="todo" type="hidden" value="disable" />
<input name="field" type="hidden" value="cnn_admin" />
</form></div></td>
</tr>
<tr>
<td class="row1">
<span class="tableItemTitle">test2</span></td>
<td class="row1" width="2%">
<div align="center"><form action="connect.php" id="form_index_2" method="post">

<img alt="" onClick="document.getElementById( 'form_index_2').submit();" src="include/theme/default/images/inactive.png" />
<input name="usr_id" type="hidden" value="10" />
<input name="cnn_pg" type="hidden" value="2" />
<input name="todo" type="hidden" value="enable" />
<input name="field" type="hidden" value="cnn_index" />
</form></div></td>
<td class="row1" width="2%">
<div align="center"><form action="connect.php" id="form_admin_3" method="post">
<img alt="" onClick="document.getElementById( 'form_admin_3').submit();" src="include/theme/default/images/inactive.png" />
<input name="usr_id" type="hidden" value="10" />
<input name="cnn_pg" type="hidden" value="2" />
<input name="todo" type="hidden" value="enable" />
<input name="field" type="hidden" value="cnn_admin" />
</form></div></td>
</tr>
</table>


Er sagt:

Line 119 column 20: there is no attribute "onClick".

<img alt="" onClick="document.getElementById( 'form_index_0').submit();" src="in

You have used the attribute named above in your document, but the document type you are using does not support that attribute for this element. This error is often caused by incorrect use of the "Strict" document type with a document that uses frames (e.g. you must use the "Transitional" document type to get the "target" attribute), or by using vendor proprietary extensions such as "marginheight" (this is usually fixed by using CSS to achieve the desired effect instead).

This error may also result if the element itself is not supported in the document type you are using, as an undefined element will have no supported attributes; in this case, see the element-undefined error message for further information.

How to fix: check the spelling and case of the element and attribute, (Remember XHTML is all lower-case) and/or check that they are both allowed in the chosen document type, and/or use CSS instead of this attribute.


Das waere praktisch diese Zeile:

<img alt="" onClick="document.getElementById( 'form_index_0').submit();" src="include/theme/default/images/active.png" />
Ich werd jetzt mal das mit dem input type versuchen, aber ich befuerchte dass ist dann kein submit bzw. ich kann das onclick auch nicht verwenden.

Ach, und das alt="" prangert er nicht an!

Pingu
20-03-2006, 19:44
Ich würde statt onClick einfach mal onclick schreiben (siehe hier: http://www.w3.org/TR/xhtml1/#h-4.2).

Pingu

nul
20-03-2006, 22:52
@Pingu: Genau das wars - verdammt, ich wusste dass XHTML alles in Kleinbuchstaben macht, warum bin ich da nicht selbst draufgekommen dass es das war.

Hab mittlerweile auch die Java-Script-Inkompartibilitaeten zu XHTML entfernt, jetzt ist das ganze Projekt kompatibel *freu*.