Jump to content

Radio Button Navigation


Guest elthomo

Recommended Posts

Guest elthomo

Ok what I want to do is navigate via the 5 radio buttons I created.

 

 

<?PHP

$hoeveel = 'unchecked';
$betalingsregaling = 'unchecked';
$afspraak = 'unchecked';
$doorgeven = 'unchecked';
$vraag = 'unchecked';



if (isset($_POST['Submit1'])) {

$selected_radio = $_POST['infotype'];

if ($selected_radio = 'hoeveel') {
$hoeveel = 'checked';
}
else if ($selected_radio = 'betalingsregaling') {
$betalingsregaling = 'checked';
header("Location: page2.php");
}
else if ($selected_radio = 'afspraak') {
$afspraak = 'checked';
}
else if ($selected_radio = 'doorgeven') {
$doorgeven = 'checked';
}
else if ($selected_radio = 'vraag') {
$vraag = 'checked';
}

}

?>

The HTML FORM code:

<FORM name ="form1" method ="post" action ="?">

<Input type = 'Radio' Name ='infotype' value= 'hoeveel'
<?PHP print $hoeveel; ?>
>Ik wil weten hoeveel ik nog dien te betalen.

<br>

<Input type = 'Radio' Name ='infotype' value= 'betalingsregaling'
<?PHP print $betalingsregaling; ?>
>Ik wil een betalingsregaling treffen.

<br>

<Input type = 'Radio' Name ='infotype' value= 'afspraak'
<?PHP print $afspraak; ?>
>Ik wil een afspraak maken

<br>

<Input type = 'Radio' Name ='infotype' value= 'doorgeven '
<?PHP print $doorgeven; ?>
>Ik wil iets doorgeven. (bijvoorbeeld adreswijziging)

<br>

<Input type = 'Radio' Name ='infotype' value= 'vraag'
<?PHP print $vraagl; ?>
>Ik heb een vraag

                                                    
<P>
<Input type = "Submit" Name = "Submit1" VALUE = "Welke informatie wil u hebben?">
</FORM>

 

 

I have found this code which may possibly do what I want but I'm unsure where to put it within my code to make it work(assuming it will work with my code.)

 

<?php
if($_POST['selected_radio'] == "hoeveel') {

  header("Location: page2.php");

  }
   elseif($_POST['selected_radio'] == 'betalingsregaling') {

  header("Location: page3.php");

  }
?>

Link to comment
https://forums.phpfreaks.com/topic/93479-radio-button-navigation/
Share on other sites

Guest elthomo

hey dude,

 

you typed something like

 

"

if ($selected_radio = 'hoeveel')

{

  $hoeveel = 'checked';

}

"

in ur code its actuly. you should use '==' sign insted of '='.

 

and last portion of the code i mean method is ok.

 

hope this is useful. ;)

 

 

Thanks for that and it was useful. Here is the working code in case anyone wants to use it.

 

<?PHP

$hoeveel = 'unchecked';
$betalingsregaling = 'unchecked';
$afspraak = 'unchecked';
$doorgeven = 'unchecked';
$vraag = 'unchecked';



if (isset($_POST['Submit1'])) {

$selected_radio = $_POST['infotype'];

if ($selected_radio == 'hoeveel') {
$hoeveel = 'checked';
header("Location: page1.php");
}
else if ($selected_radio == 'betalingsregaling') {
$betalingsregaling = 'checked';
header("Location: page2.php");
}
else if ($selected_radio == 'afspraak') {
$afspraak = 'checked';
header("Location: page3.php");
}
else if ($selected_radio == 'doorgeven') {
$doorgeven = 'checked';
header("Location: page6.php");
}
else if ($selected_radio == 'vraag') {
$vraag = 'checked';
header("Location: page5.php");
}

}

?>


The HTML FORM code:

<FORM name ="form1" method ="post" action ="?">

<Input type = 'Radio' Name ='infotype' value= 'hoeveel'
<?PHP print $hoeveel; ?>
>Ik wil weten hoeveel ik nog dien te betalen.

<br>

<Input type = 'Radio' Name ='infotype' value= 'betalingsregaling'
<?PHP print $betalingsregaling; ?>
>Ik wil een betalingsregaling treffen.

<br>

<Input type = 'Radio' Name ='infotype' value= 'afspraak'
<?PHP print $afspraak; ?>
>Ik wil een afspraak maken

<br>

<Input type = 'Radio' Name ='infotype' value= 'doorgeven'
<?PHP print $doorgeven; ?>
>Ik wil iets doorgeven. (bijvoorbeeld adreswijziging) 

<br>

<Input type = 'Radio' Name ='infotype' value= 'vraag'
<?PHP print $vraag; ?>
>Ik heb een vraag


<P>
<Input type = "Submit" Name = "Submit1" VALUE = "Welke informatie wil u hebben?">
</FORM>

 

Solved(sorry still don't know where the button is mark it as such)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.