Search the Community
Showing results for tags 'radio button'.
-
Hi people, I'm new to PHP, and I'm having some real difficulties with trying to re-populate a radio button selection on a form. Basically, I'm working on a WordPress plugin which uses custom fields to create a Bet custom post type. I need to have my form submit the user input, then re-populate it so that if the user wants to edit and update the Bet data, they don't have to fill in the whole form details again, they can just edit what they need to, and update (re-submit) the form. I've managed to get all of the form elements re-populating, apart from a radio button. I've been trawling round the internet for most of yesterday evening and this morning, trying different things, but nothing I've found works for me. I'd really appreciate some help if anyone knows how to do this. Here's my code so far (non working) <?php $win_status = 'checked = "unchecked"'; $ew_status = 'checked = "unchecked"'; if (isset($bet_details_bet_type)) { $selected_radio = $bet_details_bet_type; if ($selected_radio == 'WIN') { $win_satus = 'checked = "checked"'; } elseif ($selected_radio == 'EW') { $ew_status = 'checked = "checked"'; } } echo '<label for="bet_details_bet_type">Bet Type: </label>'; echo '<input type="radio" name="bet_details_bet_type" id="bet_details_bet_type" value="WIN" '. esc_attr( $win_status) .' /> Win '; echo '<input type="radio" name="bet_details_bet_type" id="bet_details_bet_type" value="EW" '. esc_attr( $ew_status) .' /> Each Way </br>'; $bet_details_bet_type is the VARIABLE that gets sent to / pulled from $_POST I have another function which is handling that, which has the following in it. $bet_details_bet_type = $_POST['bet_details_bet_type']; update_post_meta( $post_id, 'bet_details_bet_type', $bet_details_bet_type ); I know that the sending and retrieving is working okay, as the Value is stored and retrieved when I update (submit) the bet, but I just can't seem to get the radio button to be re-checked to the value that was submitted. Again, if any can help with this I would be very grateful. Thanks, Dweezer
- 4 replies
-
- radio button
- re-populating
-
(and 2 more)
Tagged with:
-
I'm developing a form which is essentially a simple set of radio buttons. Conceptually, it is like this: Please select a theme from the list: o Black o Blue o Red [submit] [Reset] I'm actually showing a slideshow of images showing the appearance of each of the themes in a slideshow that only shows one image at a time. I want my users to click on the image that represents the theme they want and, ideally, not have to click on the Submit button at all. Then I will save the name of the theme they chose in a cookie (if cookies are enabled). Many years ago, I dabbled in things like CGI and I have a vague recollection, possibly faulty, that it's not difficult to make a form that has only one set of radio buttons treat the selection of one of the radio buttons as a Submit. I don't remember how to do it though. Can anyone advise me on whether it is indeed possible and, if it is, how I make the selection of the radio button cause the form to be submitted?
-
Greetings, We have purchased a wordpress template and we needed to add some fields to the booking form. The creator told me that we I have to manually add the code. What I have decided to add is some Radio Button choices. I have attached the php file and two screenshots of the booking form. The first one is what it looks like currently, the second one is what I wanted it to look like. Here is the CSS of the booking form: /*-------------------------------------------------- /* booking /*-------------------------------------------------- */ #booking-form-main{ display:block; } .booking-form{ background:url(../images/dotwhite75.png); padding:30px 0 30px 0; text-align:center; margin-bottom:30px; display:none; } .booking-form .text-label{ padding-bottom:10px; display:block; } .booking-form input{ width:97%; border:solid 1px #bbb; } .booking-form textarea{ width:98%; height:120px; } .booking-form select{ width:102%; } .booking-form .span3{ } .booking-form i{ margin-right:8px; color:#6a4a3d; } .btn-book-submit{ margin-top:30px; } .booking-inner{ display:inline-block; text-align:left; } #btn-book-now { margin-bottom:30px; } #btn-book-now .off{ display:none; } I would really appreciate any help that you would give me page_reservation.php
- 5 replies
-
- radio button
- php
-
(and 1 more)
Tagged with:
-
Hi, I have a set of radio buttons with some integer as its value. I use them to make seat selections in an application. If a Radio button is once selected its value will be entered to the DataBase. My question, can I mask or make invisible, the radio button whose value is found in database? isa that possible? Any help will be appreciable. Thanks in advance.. Regards...
-
Hi. I'm having a problem regarding my codes involving radio buttons and subloop. I couldn't retrieve the data from post and I can't insert them to the database. I just couldn't find the error. Here's my form's code: <form method="post"> <?php $select_paragraph=mysql_query('SELECT * FROM dependency'); $questrows = 0; while($get_paragraph = mysql_fetch_array($select_paragraph)) { $TestID = $get_paragraph['testId']; $Dependid = $get_paragraph['DependencyId']; echo" <table border='1'> <tr class='classheader1'> <td align='center' class='paragraph'>". $get_paragraph['Situation']. "</td> <table>"; $select_question=mysql_query('SELECT * FROM dependentitems where DependencyId="'.$Dependid.'"'); while($get_question = mysql_fetch_array($select_question)) { echo $LitId = $get_question['LiteralId']; echo $ItemID = $get_question['ItemId']; echo" <tr><td align='left' class='paragraph'><br>". $get_question['Question']. "</td></tr> <tr><td align='left' class='paragraph'><input type='radio' name='Option".$questrows."' value = '". $get_question['Option1']. "'>". $get_question['Option1']. "</td></tr> <tr><td align='left' class='paragraph'><input type='radio' name='Option".$questrows."' value = '". $get_question['Option2']. "'>". $get_question['Option2']. "</td></tr> <tr><td align='left' class='paragraph'><input type='radio' name='Option".$questrows."' value = '". $get_question['Option3']. "'>". $get_question['Option3']. "</td></tr> <tr><td align='left' class='paragraph'><input type='radio' name='Option".$questrows."' value = '". $get_question['Option4']. "'>". $get_question['Option4']. "</td></tr> "; echo "Radio Names = Option".$questrows." "; $questrows++; } echo" </table> </td> </tr> </table> "; } ?> <input type="submit" name="enter" value="Submit"/> </form> And here's the code where I retrieve the post so I could insert them into my database: <?php if(@$_POST['enter']) { $select_paragraph=mysql_query('SELECT * FROM dependency'); $questrows = 0; while($get_paragraph = mysql_fetch_array($select_paragraph)) { $TestID = $get_paragraph['testId']; $Dependid = $get_paragraph['DependencyId']; $select_question=mysql_query('SELECT * FROM dependentitems where DependencyId="'.$Dependid.'"'); while($get_question = mysql_fetch_array($select_question)) { echo "Hi".@$option=$_POST['Option'.$questrows]; echo "<br>LitId = ".$LitId = $get_question['LiteralId']; echo "<br>ItemId = ".$ItemID = $get_question['ItemId']; echo '<br>ThisOption'.$questrows; $insertToTemp="insert into temp(StudId, TestId, ItemId, LiteralId, Choice) values(1, 3, $ItemID,$LitId,'$option[$questrows]')"; mysql_query($insertToTemp); $questrows++; echo "<br>"; } } } ?> Hope you could help me find the error. Thanks.
-
I'm trying to create a "Thank you" page where a user lands after he/she has opted into one of our forms. On that page there will be an option for the user to choose a free CD as a gift and will only have to pay for shipping. I would like to give the user an option to either choose a physical CD or a digital MP3. The logic here is that first I provide a user with selection of 4 CDs that I connect to each radio button. Then below that there will be the first Submit button that will say something like "Yes, please mail be a CD." Below the first button there will be a second Submit button that will say something like "Send me the download link instead". Thus if the user clicks on any of the radio buttons and then clicks on the first Submit button, they will be taken to the shopping cart for that CD where they will be prompted to pay the shipping charges for the CD. If the user click on that same radio button, but then clicks on the second Submit button, they will be taken to link to download it. The third link below would just take the user past the page if he chooses to opt out of this offer. I can't get the script to work correctly for me. Here is what I have so far: <?PHP $option1 = 'unchecked'; $option2 = 'unchecked'; $option3 = 'unchecked'; $option4 = 'unchecked'; if (isset($_POST['Submit1'])) { $selected_radio = $_POST['cd_choice']; if ($selected_radio == 'option1') { $option1 = 'checked'; ?> <a href="#">Purchase link 1</a> <?php } else if ($selected_radio == 'option2') { $option2 = 'checked'; ?> <a href="#">Purchase link 2</a> <?php } else if ($selected_radio == 'option3') { $option3 = 'checked'; ?> <a href="#">Purchase link 3</a> <?php } else if ($selected_radio == 'option4') { $option4 = 'checked'; ?> <a href="#">Purchase link 4</a> <?php } } else { $selected_radio = $_POST['cd_choice']; if ($selected_radio == 'option1') { $option1 = 'checked'; ?> <a href="#">Download link 1</a> <?php } else if ($selected_radio == 'option2') { $option2 = 'checked'; ?> <a href="#">Download link 2</a> <?php } else if ($selected_radio == 'option3') { $option3 = 'checked'; ?> <a href="#">Download link 3</a> <?php } else if ($selected_radio == 'option4') { $option4 = 'checked'; ?> <a href="#">Download link 4</a> <?php } } ?> Here's what I have for the HTML portion of it: <body> <FORM NAME ="form1" METHOD ="POST" ACTION ="radioButton_test.php"> <INPUT TYPE = 'Radio' Name ='cd_choice' value= 'option1' <?PHP print $option1; ?>> This is the first CD <INPUT TYPE = 'Radio' Name ='cd_choice' value= 'option2' <?PHP print $option2; ?>> This is the second CD <INPUT TYPE = 'Radio' Name ='cd_choice' value= 'option3' <?PHP print $option3; ?>> This is the third CD <INPUT TYPE = 'Radio' Name ='cd_choice' value= 'option4' <?PHP print $option4; ?>> This is the fourth CD <P> <center><INPUT TYPE = "Submit" Name = "Submit1" VALUE = "Yes, please mail me a CD"></center> <p><center><INPUT TYPE = "Submit" Name = "Submit2" VALUE = "Send me download link instead"></center></p> <div align="center"><a href="#">No thanks. </a></div> </FORM> Any help would be greatly appreciated. Thank you!
- 17 replies
-
- php forms
- radio button
-
(and 3 more)
Tagged with:
-
I have a quiz program, it is working but it shows the options of the questions in the same order ie currently the correct answer of each of the question will be displayed as the last option only. Is there anyway to display the options randomly?. Am a newbie; This is my first post here and your suggestions are sincerely appreciated. Here is my code which shows the questions and answers from the DB. mysql_select_db("quiz_k"); $exam="SELECT * FROM php"; $result=mysql_query($exam); for($i=1;$i<=20;$i++) { while($row=mysql_fetch_assoc($result)) { echo $row['id'].")"; $x=$row['id']; echo $row['question']."<br>"; ?> <input type="radio" required='required' name="<?php echo $row['id'] ?>" value="<?php echo $row['option1'] ?>"> <?php echo $row['option1'].'<br>'; ?> <input type="radio" required='required' name="<?php echo $row['id'] ?>" value="<?php echo $row['option2'] ?>"> <?php echo $row['option2'].'<br>'; ?> <input type="radio" required='required' name="<?php echo $row['id'] ?>" value="<?php echo $row['option3'] ?>"> <?php echo $row['option3'].'<br>'; ?> <input type="radio" required='required' name="<?php echo $row['id'] ?>" value="<?php echo $row['answer'] ?>"> <?php echo $row['answer'].'<br>'; } } ?> <br> <input type="submit" name="submit" value="submit" > </form> </html>