radiobutton probleem

Gestart doorTom21 reacties57 weergaven

22 berichten · pagina 1 van 2

Tom

Lid · Topicstarter

Berichten
3.868
Reputatie
0
Punten
0,02
Lid sinds
Laatst gezien
Weet iemand hoe ik dit rare probleem moet oplossen:
http://www.nolifegamer.nl/index.php?p=kop_munt
Je kan ze allebei tegelijkertijd aan doen.

Dit is de code:

<table>
<form action="index.php?p=kop_munt" method="POST">
<tr>
    <td>Kop: <input type="radio" name="a"/></td>
    <td><img src="http://www.nolifegamer.nl/img/kop.png" /></td>
</tr>
<tr>
    <td>Munt: <input type="radio" name="b" /></td>
    <td><img src="http://www.nolifegamer.nl/img/munt.png" /></td>
</tr>
<tr>
    <td></td>
    <td><input type="submit" value="Verzend" /></td>
</tr>
</form>
</table>
0
Berichten
5.795
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien




alstu
0
Tom

Lid · Topicstarter

Berichten
3.868
Reputatie
0
Punten
0,02
Lid sinds
Laatst gezien
Het werkt wel, maar nu werkt dat script niet meer.
0
Berichten
5.795
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
kan je misch de code van het script plaatsen dan kan ik kijken wat er fout aan is of wat hij niet meegeeft
0
Tom

Lid · Topicstarter

Berichten
3.868
Reputatie
0
Punten
0,02
Lid sinds
Laatst gezien
Hier het script:
http://www.plaatscode.be/138196/

Misschien dat ik het later nog ga verkopen, hier wil ik dan geen klachten over.
0
Berichten
5.795
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
je script klopt en wat gebeurt er als je het in een los bestand zet?
0
Berichten
3.788
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
<table>
<form action="index.php?p=kop_munt" method="POST">
<tr>
    <td>Kop: <input type="radio" name="munt" value="0" /></td>
    <td><img src="http://www.nolifegamer.nl/img/kop.png" /></td>
</tr>
<tr>
    <td>Munt: <input type="radio" name="munt" value="1" /></td>
    <td><img src="http://www.nolifegamer.nl/img/munt.png" /></td>
</tr>
<tr>
    <td></td>
    <td><input type="submit" value="Verzend" /></td>
</tr>
</form>
</table>
[COLOR= #0000BB]<?php
$munt[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]munt[/COLOR][COLOR= #007700]];[/COLOR]
[COLOR= #0000BB]$computer[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/rand"]rand[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]0[/COLOR][COLOR= #007700],[/COLOR][COLOR= #0000BB]1[/COLOR][COLOR= #007700]);[/COLOR]

[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]REQUEST_METHOD[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #DD0000]POST[/COLOR][COLOR= #007700]) {[/COLOR]
    [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$munt[/COLOR] [COLOR= #007700]==[/COLOR] [COLOR= #0000BB]$computer[/COLOR][COLOR= #007700]){[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Gefeliciteerd! Je hebt gewonnen!"[/COLOR][COLOR= #007700];
    }[/COLOR]
    [URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Helaas, je hebt verloren"[/COLOR][COLOR= #007700];
    }
}[/COLOR]
?>


Dit zou gewoon moeten werken!
0
Berichten
3.788
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
<table>
<form action="index.php?p=kop_munt" method="POST">
<tr>
    <td>Kop: <input type="radio" name="munt" value="0" /></td>
    <td><img src="http://www.nolifegamer.nl/img/kop.png" /></td>
</tr>
<tr>
    <td>Munt: <input type="radio" name="munt" value="1" /></td>
    <td><img src="http://www.nolifegamer.nl/img/munt.png" /></td>
</tr>
<tr>
    <td></td>
    <td><input type="submit" value="Verzend" /></td>
</tr>
</form>
</table>
[COLOR= #0000BB]<?php
$munt[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]munt[/COLOR][COLOR= #007700]];[/COLOR]
[COLOR= #0000BB]$computer[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/rand"]rand[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]0[/COLOR][COLOR= #007700],[/COLOR][COLOR= #0000BB]1[/COLOR][COLOR= #007700]);[/COLOR]

[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$munt[/COLOR] [COLOR= #007700]==[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700]){[/COLOR]
    [COLOR= #0000BB]$win[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"Kop"[/COLOR][COLOR= #007700];[/COLOR]
    [COLOR= #0000BB]$lose[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"Munt"[/COLOR][COLOR= #007700];
}[/COLOR]
[URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR]
    [COLOR= #0000BB]$win[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"Munt"[/COLOR][COLOR= #007700];[/COLOR]
    [COLOR= #0000BB]$lose[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"Kop"[/COLOR][COLOR= #007700];
}[/COLOR]

[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]REQUEST_METHOD[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #DD0000]POST[/COLOR][COLOR= #007700]) {[/COLOR]
    [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$munt[/COLOR] [COLOR= #007700]==[/COLOR] [COLOR= #0000BB]$computer[/COLOR][COLOR= #007700]){[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Gefeliciteerd! Het was "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$win[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]", Je hebt gewonnen!"[/COLOR][COLOR= #007700];
    }[/COLOR]
    [URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Helaas, het was "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$lose[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]", je hebt verloren"[/COLOR][COLOR= #007700];
    }
}[/COLOR]
?>


En met deze geeft hij ook aan wat het was!
0
Tom

Lid · Topicstarter

Berichten
3.868
Reputatie
0
Punten
0,02
Lid sinds
Laatst gezien
Daiman schreef:
je script klopt en wat gebeurt er als je het in een los bestand zet?
Het script staat gewoon in een los bestand.
0
Berichten
3.225
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Het hoort erboven te staan yummieMoet bij het php gedeelte wel nog iets staan
0
Berichten
3.788
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Quote:
Het hoort erboven te staan
Moet bij het php gedeelte wel nog iets staan

WTF bedoel je?
Het hoort er helemaal niet boven te staan, je mag het neerzetten waar je wilt, tussen het formulier zelfs als je dat graag wilt, en wat moet er bij het php staan?
0
Tom

Lid · Topicstarter

Berichten
3.868
Reputatie
0
Punten
0,02
Lid sinds
Laatst gezien
Hoe bedoelen jullie allemaal? Dit is het script en zo werkt die zoals die op plaatscode.be staat, alleen dan kan je alle 2 de radiobuttons aan doen en dat wil ik niet.
0
Berichten
18.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
<table>
<form action="index.php?p=kop_munt" method="POST">
<tr>
    <td>Kop: <input type="radio" name="invoer" value="1" /></td>
    <td><img src="http://www.nolifegamer.nl/img/kop.png" /></td>
</tr>
<tr>
    <td>Munt: <input type="radio" name="invoer" value="0" /></td>
    <td><img src="http://www.nolifegamer.nl/img/munt.png" /></td>
</tr>
<tr>
    <td></td>
    <td><input type="submit" value="Verzend" /></td>
</tr>
</form>
</table>
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]REQUEST_METHOD[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #DD0000]POST[/COLOR][COLOR= #007700])
{[/COLOR]
    [COLOR= #0000BB]$invoer[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]invoer[/COLOR][COLOR= #007700]];[/COLOR]
    [COLOR= #0000BB]$computer[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/rand"]rand[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]0[/COLOR][COLOR= #007700],[/COLOR][COLOR= #0000BB]1[/COLOR][COLOR= #007700]);[/COLOR]
    [COLOR= #0000BB]$array[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/array"]array[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]munt[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]kop[/COLOR][COLOR= #007700]);[/COLOR]
    [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$invoer[/COLOR] [COLOR= #007700]==[/COLOR] [COLOR= #0000BB]$computer[/COLOR][COLOR= #007700])
    {[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Gefeliciteerd! Je hebt het goed geraden, het was inderdaad [/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$array[/COLOR][COLOR= #007700][[/COLOR][COLOR= #0000BB]$computer[/COLOR][COLOR= #007700]];
    }[/COLOR]
    [URL="http://www.php.net/else"]else[/URL]
    [COLOR= #007700]{[/COLOR]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Helaas! Je heb het niet goed geraden. Het juiste antwoord was [/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$array[/COLOR][COLOR= #007700][[/COLOR][COLOR= #0000BB]$computer[/COLOR][COLOR= #007700]];
    }
}[/COLOR]
?>


Getest en het werkt
0
Berichten
3.788
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Wat wij hebben gedaan is het script voor je herschreven, zodat het er wat beter uitziet!
Maar het antwoord op je vraag is: Je kan ze allebei selecteren omdat ze niet dezelfde naam (name) hebben.
Radio buttons horen pas bij elkaar als ze dezelfde name hebben, anders zijn het gewoon 2 loststaande!
@Luuk, slim bedacht met die arraybiggrin
0
Tom

Lid · Topicstarter

Berichten
3.868
Reputatie
0
Punten
0,02
Lid sinds
Laatst gezien
Oke, bedankt, maar ik denk dat ik mijn script gewoon blijf gebruiken.

Ik heb nu de ids veranderd, hoe zou ik dit met $_POST moeten aanduiden?

Ik heb dan nog even 1 vraag:
Hoe moet je met $_SERVER de pagina waar je nu op zit bepalen?
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren