Avatar billede tortur Nybegynder
02. april 2004 - 19:03 Der er 1 kommentar

indsæt i databasen hvilklet felt man står på?

Hey eksperter!!
Har et lille alá html problem!
Dette ryk din figur script, vil jeg have til at vise hvad felt den står på i databasen, altså at vær felt har sit eget navn som fx.: felt_1 felt_2 osv.
Og så når man klikker på et felt skal den opdatere det i databasen, så i kolonen felt står der eksempelvis felt_4.
Koden:

<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<style type="text/css">
#table {

    border-collapse: collapse;
}
#table td {
    width: 61px;
    height: 71px;
        text-align: center;
    vertical-align: middle;
    cursor: kliker;

}
</style>
<script type="text/javascript">
var last_field = null;
function moveElement(field) {
    obj = document.getElementById(field);
    if (last_field != null) last_field.innerHTML = '&nbsp;';
    document.getElementById(field).innerHTML = '<div><img src="figur.gif" height="60" widht="60"></div>';
    last_field = obj;
}
</script>
</head>

<body oncontextmenu="return false" ondragstart="return false" onselectstart="return false">

<table id="table" background="bg.bmp">
    <tr>
        <td id="1_1" onclick="moveElement(this.id)">&nbsp;</td>
        <td id="1_2" onclick="moveElement(this.id)">&nbsp;</td>
        <td id="1_3" onclick="moveElement(this.id)">&nbsp;</td>
        <td id="1_4" onclick="moveElement(this.id)">&nbsp;</td>
<td id="1_5" onclick="moveElement(this.id)">&nbsp;</td>
<td id="1_6" onclick="moveElement(this.id)">&nbsp;</td>
<td id="1_7" onclick="moveElement(this.id)">&nbsp;</td>

    </tr><tr>
        <td id="2_1" onclick="moveElement(this.id)">&nbsp;</td>
        <td id="2_2" onclick="moveElement(this.id)">&nbsp;</td>
        <td id="2_3" onclick="moveElement(this.id)">&nbsp;</td>
        <td id="2_4" onclick="moveElement(this.id)">&nbsp;</td>
<td id="2_5" onclick="moveElement(this.id)">&nbsp;</td>
<td id="2_6" onclick="moveElement(this.id)">&nbsp;</td>
<td id="2_7" onclick="moveElement(this.id)">&nbsp;</td>
    </tr><tr>
        <td id="3_1" onclick="moveElement(this.id)">&nbsp;</td>
        <td id="3_2" onclick="moveElement(this.id)">&nbsp;</td>
        <td id="3_3" onclick="moveElement(this.id)">&nbsp;</td>
        <td id="3_4" onclick="moveElement(this.id)">&nbsp;</td>
        <td id="3_5" onclick="moveElement(this.id)">&nbsp;</td>
        <td id="3_6" onclick="moveElement(this.id)">&nbsp;</td>
        <td id="3_7" onclick="moveElement(this.id)">&nbsp;</td>
    </tr><tr>
        <td id="4_1" onclick="moveElement(this.id)">&nbsp;</td>
        <td id="4_2" onclick="moveElement(this.id)">&nbsp;</td>
        <td id="4_3" onclick="moveElement(this.id)">&nbsp;</td>
        <td id="4_4" onclick="moveElement(this.id)">&nbsp;</td>
        <td id="4_5" onclick="moveElement(this.id)">&nbsp;</td>
        <td id="4_6" onclick="moveElement(this.id)">&nbsp;</td>
        <td id="4_7" onclick="moveElement(this.id)">&nbsp;</td>
    </tr>
<tr>
        <td id="5_1" onclick="moveElement(this.id)">&nbsp;</td>
        <td id="5_2" onclick="moveElement(this.id)">&nbsp;</td>
        <td id="5_3" onclick="moveElement(this.id)">&nbsp;</td>
        <td id="5_4" onclick="moveElement(this.id)">&nbsp;</td>
        <td id="5_5" onclick="moveElement(this.id)">&nbsp;</td>
<td id="5_6" onclick="moveElement(this.id)">&nbsp;</td>
        <td id="5_7" onclick="moveElement(this.id)">&nbsp;</td>
    </tr>
</table>

<script type="text/javascript">moveElement('1_1');</script>

</body>
</html>

Håber jeg kan få hjælp eksperter!
På forhånd tak...
Avatar billede roenving Novice
02. april 2004 - 19:30 #1
Hvordan får din database noget at vide ?-)

-- og så skal du lige være opmærksom på, at det faktisk ikke er lovligt at starte id'er med tal, men det betyder vel heller ikke noget, at du f.eks. sætter et 'f' foran ...

(se evt. http://www.w3.org/TR/html401/types.html#type-name !-)
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Vi tilbyder markedets bedste kurser inden for webudvikling

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester