PHP - If Date Equils X Then Radio Button Disabled?
I need a calendar that is setup if you select a date that is within a 7 days of the current date then a radio button the the page is not available to be selected.
Similar TutorialsHi all , here is a question about a disabled button . If I have a button: Code: [Select] <input id='submit' type='submit' disabled='disabled' value='submit'> Is it possible to change the "disabled=true" through php function ? such as Code: [Select] function change_button(){ echo "<script language=\"javascript\">"; echo "document.getElementById('submit').disabled=true;"; echo "</script>"; } I tried it , not working...is this function possible or have I make any mistake ? Thanks for every reply . I dont want unset onclick="this.disabled=true" if page refresh, code :
<button type="button" class="addb btn btn-primary rounded-pill py-2 btn-block" type="submit" data-voice_sku="'.$row["voice_sku"].'" data-voice_name="'.$row["voice_name"].'" onclick="this.disabled=true">Add to Playlist</button>
If page refresh onclick event unset. how to prevent? I have a function to display some images and allow a user to select a choice via a radio button.The value is then passed to another function. I have 2 problems My selection is not being passed back and I cant assign the value to a query sring in a link to another page. On the form do i need to add checked? Any help appreciated. Code: [Select] function cover() { echo'<h2>Please upload your book cover or choose one from the selection</h2> <p>All book ideas require a cover. Your choice can be changed at a later date.</p>'; //process selection of cover if (isset($_POST['submit'])) { $coverID=$_POST['cover']; echo $coverID; ?>   <ul><li class="demo-menu-link"><a href="?page=submenu7&coverID=$coverID">Finnished Cover</a></li></ul><?php exit(); } else{ echo "not Submitted"; } global $wpdb; $query = "select * from wp_cover"; $result = mysql_query($query) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error()); echo mysql_error(); if (!$result){ return false; } echo'<div class="wrap"><p>choose from one of the covers below</p></div>'; ?><form action="<?php $_SERVER['PHP_SELF'] ?>" method="POST" id="cover" enctype="multipart/form-data"> <table><tr><?php /* display picture and radio button */ while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $coverID=$row['coverID']; echo"<img src=\"/wordpress_3/wp-content/plugins/Authors2/jackets/{$row['pix']}\" />"; echo"<td>"; echo $coverID; echo "<Input type = 'Radio' Name ='cover' value= '$coverID'/>"; ?> </tr></table> <input type=submit value=submit> </form><?php } } Hello, I had 3 radio buttons with the same name, well, I had created 3 text box that are next to those 3 radio buttons. When I click save to the form, I need to know which radio button had been pressed, so that I can detect & retrieve its value. Any help? Thanks What am I doing wrong with this selected radio button? <form action="Process/privacy.php" method="post" enctype="multipart/form-data" id="privacy"> <div id="privacy_vis">Your profile is visible to:</div> <div id="privacy_select"> <label> <input name="RadioGroup1" type="radio" id="RadioGroup1_0" value="1" <?if($visible=="1")echo 'checked="checked"';?> /> Everyone</label> <label> <input name="RadioGroup1" type="radio" id="RadioGroup1_1" value="0"/> Members Only</label> </div> <br /> <div id="privacy_vis">Your Password to view your private pictures is:</div> <div> <input name="pictures_pw" type="text" id="pictures_pw" value="<? echo "$xxx_pw" ?>" size="50" maxlength="20" /> </div> <br /> <div> <input name="submit" type="submit" class="button" id="submit" value="Save Changes" /> </div> </form> </div> I am trying to have the text alongside the radio button trigger the radio button (cannot use < a href ) e.g. () Trigger with this text The closest I have found is <label for="r1"><input type="radio" name="group1" id="r1" value="1" /> button one</label> But it does not seem to work? Any help greatly appreciated how do you make it so that a radio button is either checked or unchecked based on database? Good Day, I juz like to know if there any other alternative way for the code below, coz i can't update my form when i use this method for radio the button. It's not passing the value. Code: [Select] Edit.php <tr> <td height="36" align="center" valign="middle" bgcolor="#990000"><div align="left" class="style4">Destroy :</div></td> <td align="center" valign="middle" bgcolor="#990000"><div align="left"> <label> <input type=radio name=destroyR value="Yes" <?php echo ($rows['destroy']=='Yes') ?'checked="checked"':''; ?> />Yes</label> <label> <input type=radio name=destroyR value="No" <?php echo ($rows['destroy']=='No') ?'checked="checked"':''; ?> />No</span></label> </div></td> </tr> I am trying to make a set of radio buttons that when you make a selection, it displays a sorted database from MYSQL. I have the MYSQL part figured out but I cannot figure out how to properly display it. I have the following code and I made a select screen just to test: index.html <html> <body> <form action="select.php" method="post"> <input type="radio" name="table" value="table1"> Table 1 <br> <br> <input type="radio" name="table" value="table2">Table 2 <br> <br> <input type="radio" name="table" value="table3">Table 3 <br> <br> <input type="radio" name="table" value="table4">Table 4 <br> <br> <input type="radio" name="table" value="table5">Table 5 <br> <br> <input type="Submit" Name = "submit" value="Submit"> <input type="Reset" value="Reset"> </form> </body></html> select.php <?PHP $selected_radio = $_POST["table"]; if ($selected_radio = = 'table1) { echo "Table 1 Here."; } else if ($selected_radio = = 'table2') { echo "Table 2 Here."; } else if ($selected_radio = = 'table3') { echo "Table 3 Here."; } else if ($selected_radio = = 'table4') { echo "Table 4 Here."; } else if ($selected_radio = = 'table5') { echo "Table 5 Here."; } ?> These are two separate files. When I go to run the code, no matter what I pick, the next page is always blank. Again, the select.php is just suppose to be a check, the real code will display the table instead of echoing a message. I have a group of 4 radio buttons. my mysql database knows which one the user selected previously when they stored some information. I now wish to display the same buttons but have radio button checked that the user chose before. I know this can be done but having one of those mind melt moments where I cannot think of the solution so I have 4 buttons that look like this Code: [Select] <input type="radio" name="clarity" id="clarity" value="Opaque"> Opaque<br> <input type="radio" name="clarity" id="clarity" value="Deep"> Deep<br> <input type="radio" name="clarity" id="clarity" value="Mid"> Mid<br> <input type="radio" name="clarity" id="clarity" value="Pale"> Pale<br></td> I just need to attached a checked field to the correct item This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=346803.0 i would like to display the value of the selected radio button on the same page... what i want is just reload the page and if there is a radio button selected displays it but i cant display it <?PHP if (isset($_GET["submit"])) { echo $_GET["myradio"]; } ?> <html> <head> </head> <body> <form action="<?PHP $_SERVER["PHP_SELF"]; ?>" method="get"> One <input type="radio" name="myradio" value="one"> Two <input type="radio" name="myradio" value="two"> <a href="<?PHP $_SERVER["PHP_SELF"]; ?>" name="submit">test </a> </form> </body> </html> please help guys...thanks Hi, I have 2 radio button's within a table and need to pass this array. All other rows within my table can be sent as array's and captured using $_POST['field_name'][$ROW 1 value etc]. However for radio buttons this doesn't work. As an example, a standard textbox I can send an array using the following: echo "<td width='33%'><input type='Textbox' width='100%' id='test' name='test[]' value='" .$row['test']. "'></td>"; I can then capture it using: $test = $_POST['test'][$iLine]; This works, no problem, however for radio buttons, I can't use a static array name, as presumably it dumps all rows into the array, if I do this, only the last row has a checked button, hence I need to use the following (where $checked includes the logic to decide whether the button should be checked or not, this works correctly): echo "<input type='radio' name='".$row['venue_id']."[]' value='1'".$checked."/>P1" echo "<input type='radio' name='".$row['venue_id']."[]' value='0'".$checked2." />P2"; I tried using the following: var_dump($_POST[$row]['game_id'][$iLine]); But this just returns a null value. Any ideas? This topic has been moved to HTML Help. http://www.phpfreaks.com/forums/index.php?topic=317717.0 Hello I'm working on a program that collects the Yes and No responses via a radio button. If I receive 2 or more answers of Yes I will need to send out and email otherwise nothing will happen. Can someone please tell me how can I get my Yes to work by collect the number of Yes responses?? Thank you in advance. I am having some difficulty with accessing radio button values with PHP code. Please see the attached file
Attached Files
x.txt 530bytes
11 downloads i have an rsvp page where the table is populated by guests according to event selected in the drop down list. the rsvp table has 2 columns: guest names and status. status(radio button) is divided into 3: unconfirmed(default status), attending and not attending. user has to choose either one. but i am having trouble saving the status. tia for any help!
this is the saving code:
<?php if(isset($_SESSION['sess_user_id'])) { if(isset($_POST['save-rsvp'])) { require "connection.php"; $name = $_POST['name']; $radio = $_POST['rsvp']; $session = $_SESSION['sess_user_id']; $rsvp = $dbh->prepare("UPDATE guest SET status = ? WHERE guser_id = ? AND guest_name = ?"); $rad = implode("','", $radio); for($i = 0; $i < count($_POST['name']); $i++) { if(trim($_POST['name'][$i]) !== '')// validate this form { $rsvp->bindParam(1, $rad, PDO::PARAM_INT); $rsvp->bindParam(2, $session, PDO::PARAM_INT); $rsvp->bindParam(3, $name[$i], PDO::PARAM_STR); $rsvp->execute(); } } } } ?>which when save doesn't save according to status selected. for example 5 names: noreen, pete, marzuki, nora, mishal noreen unconfirmed pete attending marzuki attending nora attending mishal not attending micah not attending when saved, all is saved as unconfirmed. noreen not attending pete attending marzuki not attending nora attending mishal not attending micah attending when saved, all is saved as not attending. noreen attending pete not attending marzuki attending nora not attending mishal attending micah not attending when saved, all is saved as attending. it seems to save according to first choice. It seems to only wanting to tick the enabled radio button even if the row value is 1 for disabled in the database. <?php while ( $row = mysqli_fetch_array ( $result, MYSQL_ASSOC ) ) { echo ' <tr> <td>' . $row['fullname'] . '</td> <td style="text-align:center;"><input type="radio" value="0" name="' . $row['fullname'] . '" class="status"'; if($enabled == 0) echo ' checked="checked"'; echo '/>Enabled'; ?> <?php echo '<input type="radio" value="1" name="' . $row['fullname'] . '" class="status"'; if($enabled == 1) echo ' checked="checked"'; echo ' />Disabled</td> </tr>'; } ?> I have page with male female radio button Here's the code Code: [Select] $qry=mysql_query("SELECT * FROM reg_table where id=$id "); $res=mysql_fetch_array($qry); $radio = $res['gender']; switch($radio) { case "male": $mal = "checked"; break; case "female": $fem = "checked"; break; } Code: [Select] Gender: <br /> <input type="radio" name="colour" value="male" checked="<?php $mal; ?>" />Male <input type="radio" name="colour" value="female" checked="<?php $fem; ?>" />Female Whats the use of checked in <input type="radio" name="colour" value="male" checked="<?php $mal; ?>" /> Hey all, I'm almost too embarrased to post this as I'm sure it is very simple - but for the life of me I can't get this to work. I am a complete newbie to PHP so please bear with me.. What I'm trying to do is to write a program that will go on to calculate a user's Body Mass Index (BMI) based on user inputted data of height and weight. However, I want to be able to accept heights and weights in a number of different units for maximum ease of use. I am trying to write some PHP code that will handle this , the main goal is to convert everything into 'cm' and 'kg' before going on and doing the simple BMI calculation later on. However I am stuck at this point: I have a text field for users to input their weight into. This is immediately followed by two radio buttons for the user to select which units they are inputting their weight in (kilograms or pounds). A third option to input their weight is given after this for those wishing to input their weight in 'stones and pounds'. My problem is as follows: I can't get my code to recognise which radio button (either 'kg' or 'lbs') has been pressed. What should happen is that my code can tell something has been inputted in the text box AND which of the radio buttons has been selected. From this it does one of the two; for the kilogram option it leaves the value as it is, but if the weight has been inputted in pounds (and the 'lbs' radio button selected) then I want the code to convert this into kilos by multiplying by 0.4535. Here is what I have so far (sorry its a bit messy - like i say I am a newbie): <?php //convert.php $ft = $cm = $inches = $weight = $stones =$pounds = $kilos = $units = ""; if(isset($_POST['cm'])) $cm = sanitizeString($_POST['cm']); if(isset($_POST['ft'])) $ft = sanitizeString($_POST['ft']); if(isset($_POST['inches'])) $inches = sanitizeString($_POST['inches']); if(isset($_POST['weight'])) $weight = sanitizeString($_POST['weight']); if(isset($_POST['stones'])) $stones = sanitizeString($_POST['stones']); if(isset($_POST['pounds'])) $pounds = sanitizeString($_POST['pounds']); if(isset($_POST['kilos'])) $kilos = sanitizeString($_POST['kilos']); if(isset($_POST['units'])) $units = sanitizeString($_POST['units']); if ($ft != '') { $height = intval(($ft * 30.48) + ($inches * 2.54)); $out = "you are $height cm tall"; } elseif($cm != '') { $height = intval($cm); $out = "you are $height cm tall"; } else $out = ""; if ($stones != '') { $kilos = intval((($stones * 14) + $pounds) * 0.45359237); $out2 = "you weigh $kilos Kg"; } elseif($weight != '' AND $units = "kg") { $kilos = $weight; $out2 = "you weigh $kilos Kg"; } elseif($weight != '' AND $units = "lbs") { $kilos = ($weight * 0.45359237); $out2 = "you weigh $kilos Kg"; } else $out2 = ""; echo <<<_END <html><head><title>Height & Weight Converter</title> </head><body><pre> Please enter your details below <b>$out$out2</b> <form method="post" action="convert.php"> Height: <input type="text" name="cm" size="3"> cm OR <input type="text" name="ft" size="1">ft <input type="text" name="inches" size="2">inches Weight: <input type="text" name="weight" size="4" /> Kg<input type="radio" name="units" value="kg" /> lbs<input type="radio" name="units" value="lbs" /> OR <input type="text" name="stones" size="2">stone <input type="text" name="pounds" size="2">pounds <input type="submit" value="Submit" /> </form></pre></body></html> _END; function sanitizeString($var) { $var = stripslashes($var); $var = htmlentities($var); $var = strip_tags($var); return $var; } ?> |