stern Posted October 11, 2006 Share Posted October 11, 2006 I am new to php programing with little background in HTML. Most of my knowledge would be in launguages like C++, assembler and raw machine code.While I am getting better at php data manipulation and DB control (these all make sense) I for the life of me cant get the simple things to work (like radio buttons). What I want to do is make 4 buttons (can only pick one of the 4) and have the choice return a number (1-4). While I can get the buttons to show and work "visually wise) on the screen, for the life of me I cant get it to give me a value (or I at least cant find "where" I supposed to get it from).After reading a post on radio buttons on the forum I tried it, but the "create radio buttons with HTML" part has left me in the dark. Here is a code snippet from the part with the radio buttons, and hopefully someone can tell me which really stupid mistake im doing here lol switch($_post["Radiobutton"]) { case "1": $val="1"; break; case "2": $val="2"; Bbreak; case "3": $val="3"; break; case "4": $val="4"; break; default: $val="0"; echo " <div align='left'>"; echo " <table width='956' border='0'>"; echo " <tr>"; echo " #$id "; echo " $question<br><br>"; echo " </tr>"; echo " <td height='24'> </td>"; echo " <td><div align='center'></div></td>"; echo " <td><font color='#FFFF80'>A</font>"; echo " <input type='radio' name='chk' value='1'> $choice1<br>"; echo " </tr>"; echo " <tr>"; echo " <td> </td>"; echo " <td><div align='center'></div></td>"; echo " <td><div align='left'><font color='#FFFF80'>B</font>"; echo " <input type='radio' name='chk' value='2'> $choice2<br>"; echo " </tr>"; echo " <tr>"; echo " <td height='24'> </td>"; echo " <td><div align='center'></div></td>"; echo " <td><font color='#FFFF80'>A</font>"; echo " <input type='radio' name='chk' value='3'> $choice3<br>"; echo " </tr>"; echo " <tr>"; echo " <td> </td>"; echo " <td><div align='center'></div></td>"; echo " <td><div align='left'><font color='#FFFF80'>B</font>"; echo " <input type='radio' name='chk' value='4'> $choice4<br>"; echo " </tr>"; echo " </table>"; echo " </div>"; }Now im sure after looking at this some may laugh them selves silly, as there is probably a way to do it short and simple.Thank you all in advance for any help you can give a newbee :-)Paul Link to comment https://forums.phpfreaks.com/topic/23690-use-of-radio-buttons-in-php/ Share on other sites More sharing options...
mATOK Posted October 11, 2006 Share Posted October 11, 2006 I think that you need these buttons to be a part of a form <form name="something" action="file-with-switch" methos="get"> // or method="post"-- radio buttons<input type="Submit" value="Submit"></form> Link to comment https://forums.phpfreaks.com/topic/23690-use-of-radio-buttons-in-php/#findComment-107529 Share on other sites More sharing options...
stern Posted October 11, 2006 Author Share Posted October 11, 2006 That did the trick :-) thanks you so much for the help. I must really applaud all the people here, as you are all making it a lot easier for newbee's like me to learn a lot faster :-)Thank you all :D Link to comment https://forums.phpfreaks.com/topic/23690-use-of-radio-buttons-in-php/#findComment-107541 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.