PHP Conditional Setting Of Radio Button Default
I'm working on an edit inventory form, and I'm pulling a field from my database that's going to be a 'Y' or 'N'. Based upon this, I want to default the 'customizable' radio button to either checked="Y" or checked="N". Code:
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Default Selection Radio Button
I have a table where users input a date, time, and quantity for a reservation. On my page ... because I have a junk calendar and coding, every time you click a different month on the calendar or click the "book now" button without entering all the necessary data, the page refreshes and erases all the data. One significant problem is that the times display as radio buttons. Some tours have one time and some have multiple times. On the page, if there is only one time, then to make it easier for users to book tours, I inputted CHECKED into the html code. But unfortunately if the tour has multiple times, then CHECKED doesn't work for the first radio button, it defaults the last radio button because of the php loop. Code:
Setting Radio Button State
I am trying to set the state of a radio button. I do not see what I am doing wrong. Sorry, I am new at this.. I need another set of eyes to look at this snip of code. I am trying to set the radio button with this link of code: echo 'SCRIPT language=JavaScript setCheckedValue("'.$_SESSION['abbr_letter'].'");</SCRIPT>' //? <snip of code> <?php session_start(); if(!isset($_SESSION['abbr_letter'])) { $_SESSION['abbr_letter'] = 'A' } require_once 'includes/config.inc.php' require_once 'includes/header.inc.php' if (xdebug_is_enabled()) echo "enable"; else xdebug_enable(); // // Start a Form ?> <HTML> <HEAD> <link href="quotesCss.css" rel="stylesheet" type="text/css"> <SCRIPT TYPE="text/javascript"> <!-- // set the radio button with the given value as being checked // do nothing if there are no radio buttons // if the given value does not exist, all the radio buttons // are reset to unchecked function setCheckedValue(newValue) { var len = document.author_abbrv.abbr_letter.length for(var i = 0; i < len; i++) { document.author_abbrv.abbr_letter[i].checked = false; if(document.author_abbrv.abbr_letter[i].value == newValue.toString()) { document.author_abbrv.abbr_letter[i].checked = true; } } } -->
Passing Radio Button Values To A Submit Button (gif)
How do i pass the value of the radio button to be put of the action that includes the value as part of the URL being submitted - "/ picked.php?pick_num=". Any help with be appreciated. Thanks <form method="post" action="/picked.php?pick_num=".<php? $value ? <input type="hidden" name="cmd" value="0"> <table width="100%"> <td align="center"> <INPUT TYPE='RADIO' NAME='pick_1' VALUE=Ƈ'>Day; <INPUT TYPE='RADIO' NAME='pick_2' VALUE=ƈ'>Week; </td> </tr> <tr> <td align="center"><input type="img src="/images/pick_now.gif" BORDER="0" name="send"></td> </tr> </table>
Setting An Image Field As A Default?
In my application I have 6 image fields. If a user uploads an image they must upload an image 1 which is the main image. So I dont want them to be able to jump to the 2nd or 3rd fields and upload their file there. I am just not sure how to go about defaulting them to upload image 1 first?
Radio Button
What i want to do , is when someone click a radio button , a text will load up at the bottom at the page , without the whole page be reloaded, i ave 0 idea how do it , just the readfile maybe...
Radio Button
I have a radio button: <input type = "radio" name = "id" value = ""> The info that needs to be put into value field is $id. I know that I can not put $id there. If I put 7 there, it works with no problem. I am getting the $id value from a database. Any ideas on how to handle this.
Radio Button Problem
from one radio button on Cilck is it possible to get 3 values as the attached image having folder jpg's but i want to use radio button in place of that so that i can use in my PHP file.
Passing Var For Radio Button
I passed as variable (temp) from one php page to a php preview page - radio buttons "hot" and "cold". Now, I want to pass it back to the first page so the radio button can be checked when someone wants to go back to change it. The plan is to check if it's page 2 value is "hot" or "cold". If hot, echo an input line in the form going back to the first page. If cold do the same but with a diff name. Then on the first page check if "hotchecked" is true. If true then php puts "checked" in the input of the radio button form making it checked as before the preview. If "coldchecked" the same would happen making cold button checked. This code below crashes when I try to get the value for comparison... ------------------------------------- <?php if ($HTTP_POST_VARS["temp"]=="hot") { echo "<input type="hidden" name="hotchecked" value="sss">"; }?> <?php if ($HTTP_POST_VARS["temp"]=="cold") { echo "<input type="hidden" name="coldchecked" value="sss">"; }?> ---------------------------------------
Radio Button Output
i have a little form with some radio buttons rate 1 to 5 kinda thing. my script mails me when submitted but it is blank even though i selected the buttons. i have done this with regular text fields with no problem but i think the out of the radio buttons needs to be different Code:
Radio Button Selected
What I wish to do is have a radio button pre-selected depending on what is pulled from the database. For example if I had 2 radio buttons: o Yes o No One has the value 1 and the other has the value 0 If 1 is selected from the database then Yes is pre-selected, else 0 is pre-selected. How would I do this?
Programmatically Setting A Radio Buttones
I am trying to programmatically set a radio button in a table of radio buttons. I have two problems with the code below: 1 - I can not prepare the <Formstatement to be printed by php. (syntax of the hyphens, quotes) my fault! 2 - If I delete the <Formand </Formstatements I can build the table of radio buttons correctly, HTML wise. The fifth radio button has 'checked=True'. The problem is even though I set radio button 5 to be checked only the last radio button is checked when it is displayed on the screen. But viewing the page code says it should be the fifth radio button. Anybody have some ideas, I'm lost. <?php /** Http://localhost/quotes/scrap.php?X...ART=tswebeditor */ if(isset($_POST['abbr_letter']) ) { $selectedNum = $_POST['abbr_letter']; } else { $selectedNum = 1; } $value = 0; $checked = 'false' $selectedNum = 5; $ColumBrake = 13; print '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' print '<html xmlns="http://www.w3.org/1999/xhtml">' print '<HTML>' print '<HEAD>' print '<title>Testiing radio Buttons</title>' print '<link href="quotes.css" rel="stylesheet" type="text/css">' print '<SCRIPT language=JavaScript src="quotesCss.js" type="text/javascript"></SCRIPT>' // print '<b><FORM NAME="author_abbrv" method="POST" action="'.<?php echo $_SERVER['PHP_SELF'];?>.'"></b>' print '</HEAD>' print '<table><tbody><tr>' foreach (range('A', 'Z') as $letter) { if( $value == $ColumBrake) { print '</tr><tr>' } if( $value == $selectedNum) { $checked = 'true' print '<td><input type="radio" name="abbr_letter" value="'. $value .'" checked="'. $checked . '" onclick="submit()" />'.$letter.'</td>' } else { $checked = 'false' print '<td><input type="radio" name="abbr_letter" value="'. $value .'" checked="'. $checked . '" onclick="submit()" />'.$letter.'</td>' } $value = $value +1; } print '</tr></tbody></table>' // print '</FORM>' print '</HTML>' ?>
Validate Button Radio In Form
I use php and javascript on a form. My validate script doesn't work with radio button. What's wrong? I want to be sure that one of the button is press. M or F I get on my first page:
How Do I Display Radio Button Results?
I have a form which uses several radio buttons to enter data. It works fine as far as entering goes, but I can't figure out how to display which button is checked when I view the record. I could do a if-then routine but it seems like there should be an easier way.
Radio Button/Checkbox Value Passing
I have a simple 3 page registration form. One form, one "data validation" script and one "insert into database" script. The customer bounces back and forth from the form to the verification script until the data is all correct. (When I say bounces, I mean logically. All the customer ever sees is the registration form, plus or minus error messages.) The problem I am having, is that if verification fails, the customer is redirected to the form. I am able to pass the input values from the "data validation" script back to the registration form using this method: <input id="Name" name="Name" type="text" value="<?php echo $Name ?>> It works well, but I don't know how to pass the variable of a radio button or check box back. I remember in javascript and other similar languages you could do something like: checkbox.value=checked Is there a way to do this in PHP? What I am attempting to do, is make is so that if the customer chooses YES on a radio button and the form is submitted,; ifthey are sent back to the form to correct an error, the radio button YES is still checked. I am not just trying to pass the variable, but to also make it select the right option when it goes back. (Or is this just more of an HTML question, at which point I will ask elsewhere)
Radio Button Not Showing Preselected In FF
I havea a PHP form that is working as expected, when there is an error the user is prompted to fix it before they can move on. I have a series of radio buttons generated from an array. I use a quick if check to see if the array value matches the post value so the radio button can be turned on or not. In the rendered HTML you can see the value "checked" in the radio button field, and the radio button displays checked in IE, but not in FF. Any thoughts? PHP Code:
Multiple Radio Button Groups - Please Help! :)
I'm having a problem with multiple radio button groups within a while loop. I have the page made so it pulls from a database the row values - one of which is a Y or N value. I have a radio button group for the Y and N value for each row of the database that gets pulled but only the last row will populate the value retrieved from the db. I know that I have to create a unique name for the radio buttons for each row
Radio Button To Post Variable ?
how do i post the below code of a radio button as the name is a variable called $button_name? <td align="center"><input type="radio" name='.$button_name.' value = '.$orderId.' unchecked> Selected</td> The line below doesnt seem to be takin the value to the other page, iv tried " " around the variable but dont work? Code:
Radio Button Values Won't Post To SQL DB
I have a form with radio buttons. I typically don't use them and thought I would take the time to figure them out this time. The values won't post to the database. Please let me know what I'm doing wrong here. The joint field is a yes/no question with 2 radio buttons: Code:
Radio Button Group Value Caption
I have 2 radio buttons in a group named Gender one being male and one being female, now how would i get the value from the user's choice out of the two radio buttons and assign it to an $Gender variable..?
Setting Radio Buttons Via A Tables Results.
I'm generating a dynamic table based on a SQL call to a database. For each row returned I need four radio buttons in a group which somebody can make a decision on. The above is no problem but what I want to do is at the same time set the radio buttons to the correct figure based on the data returned. PHP Code:
Passing Radio Button Form Data
I am running php as a sapi module on winXP with Apache. I am passing the data from a radio button from one page to another to be processed. For some reason it seems to be passing no data - for example in the 1st page I would have 3 radio buttons in a loop: <input type='radio' name='radio' value="<?php echo $val ?>"> I would then attempt to read the data in page 2 : <?php echo $radio ?> but this comes up empty. I tried using "get" in my form, and although the name/value pair appears in the URL string, it does not pass itself to the $radio variable in the next page. What the??? Does anyone know of any reason why php would NOT allow a radio button (or any other form object) it's data to pass on. I am not using sessions.
Radio Button - Reading Pre Selected Values From Db
I am able to make a selection of information when entering a record, with radio buttons giving the option of yes, or no. Which stores their answer as yes, or no in the database. I then have an update record page that reads information in the database, and presently it will not retrieve the previously selected option from the database. I have tried all sorts of if else statements, and can't get anything to work. I want the previously selected option to be selected when they are entering the update page. Thus, they have the option to change it, but want their previous setting selected so they are aware of their currently selected option is. <td width="50%"> <input type="radio" name="ud_digdocs" value="Yes">Yes <input type="radio" name="ud_digdocs" value="No" checked>No
Mapping Radio Button Set To Multiple Fields
I've been staring at a form for about a day now and hope a fresh set of eyes can shed some light on it. It has a couple of issues, but here's the first: I'm trying to map a set of four radio buttons to eight fields in a MySQL database. If you select Radio Option 1, for example, that value should be passed into SQLField1, the now() value passed into SQLField2, and SQLField3 through SQLField8 would be passed no value. Code:
Create Radio Button Group WHERE Other Fields Can Disappear?
I'm trying to create radio buttons on my form where if one radio button is selected, then other fields disappear. Here is classic example: Do you have a passport? o NO o YES, if so Date issued: [date pull down menu] See what i mean? If the user clicks NO, then the "yes" selection as well as the Date pull down menu will turn grey so that the user cannot select it anymore. Is it possible doing this without reloading the page?
Select From Radio Button + Enter Username = Open User Profile
I have 4 radio buttons. each button to determine which page to go to. But before page open user enters username in a text box. So when submitted, Page opens relevant to that user displaying selected page. Page 1: <radio button> >>>>>>>>>> this page to go to page1.php (this is a table of user records 1) Page 2: <radio button> >>>>>>>>>> this page to go to page2.php (this is a table of user records 2) Page 3 :<radio button> >>>>>>>>>> this page to go to page3.php (this is a table of user records) 3 Page 4: <radio button> >>>>>>>>>> this page to go to page4.php (this is a table of user records 4) Enter Username: [text box] >>>>>>>> any user with their username [submit] Result should be : If User FAB5 selects radio button 1 >>>>>>>>>. to display FAB5's page1.php
Database Stores Default Number Everytime, But I Havent Set A Default Number??
Im having some problems with my database. Everytime i store a number which is longer than 10 numbers the script or database puts this number into the database: 2147483647. Its does this everytime no mather how i write the numbers and nomather how long the number is, it just needs to be over 10. I have set any default value in the database and to be sure i havent i tried deleting the table, but same thing happends again???
Upload File Having Browse Button And Submit Button On Same Form
I am building a form where the user must upload a picture and fill in his details. Now I have a problem as all of this is on the same form. How will I be able to have the Browse button to open the "file browse" dialog and the Submit button to submit the form data. As I believe you can not use GET but must use POST method for form. Is there any means that I can use GET cause I need to get form variables from URL as well.
Setting Cookies, Setting Timestamp Instead...
im setting cookies for my login and instead of storing the values i want it to, its storing a timestamp instead my code is in a few pages, althoug ill summerise my data, and only post the code that creates the cookies: Code:
Image Button Vs. HTML Button
I have a form I've been working on trying to get working, and to my surprise, the only reason it wasn't working was because the submit button was an image. PHP Code:
Conditional Loop
I have one table, "players" that has player info including start season (year). I then have a table for each season with player stats, i.e. games played etc called stats200X where X is the year obviously. I have no problem with extracting data from the current year, but what I would like to do is get data from previous years too. I was thinking about doing something like: (year) - (startyear), which for example could be 3. I don't know where to begin, but I want to be able to loop though previous years so that, if tables exist of course, I could do select * from stats{Y -1} display select * from stats{Y -2} etc Would I need to hard code this or is there a way of doing this though a conditional loop?
Conditional Login..
I have a form with a username & password field along with 3 radio buttons. What I basically want to achieve is if radio button A is checked it will post the username & pass to a.php, If button B is checked it will post the username & pass to b.php and so on for button C.
Checkboxes,conditional
Basically I have what seems to be a very small problem but I am driving ny self mad trying to figure out what the problem is. Here is what I have: I have a form with two checkboxes: <input type="checkbox" name="medicalcheck" > <input type="checkbox" name="dentalcheck" > the form is posting the a php file, decision.php, that simple checks to see if the boxes have been checked and performs an operation in either case. Here is the code:
Once Conditional Causes Error, The Other Doesn't...why?
There are 2 if statements at the beginning of this code snippet. The one that is currently commented out works while the one that is not commented out yields this error Parse error: syntax error, unexpected '{' in C:xampphtdocsench2index4.php on line 106 I am just not seeing why. Code:
Conditional Structures
I am wondering about conditional structures and the depth of nesting allowed, if at all. For example I know I can do this: Code:
Conditional Form
I want to condtionally display an HTML form. I havnt got a clue how it can be done, I suppose its the same way as putting html tables in php, but I cant get it to work. Here is the condtion: <?php if (!empty($pk)) { And here is the form: <form action="google.php" method="GET" name="deleteForm" > <input type="hidden" name="pk" value="<? echo $pk;?>"> <input type="submit" value="Delete"> </form>
Conditional Third Expression In For Loop
Is it possible to make expr3 $i++ under one condition and $i-- under another? Instead of having the condition outside the loop and having two loops. Or I could just use a while loop, I guess.
Sessions + Conditional Include
I am having a little problem in trying to figure out why my session state is not expiring after I close the browser window. Having been used to the ASP way of doing things I am trying to get my head around this slightly different method of handling sessions in PHP.... What happens is that I log on to the site, do various things and then close it when I am finished. I return the next day to find that the 'logged in' menu is displayed first which shouldnt happen until you have logged in again. I assumed that the session was been stored as a cookie but wasnt been released after the session terminates by default, but found I was wrong when I deleted all my internet files and went back to the site. My code for the first page is as follows..
Conditional PHP Cookies; If Cookie = 1 Do This...
I've figured out cookies ... now I'm trying to combine them with if conditions. For cookie 'bandwidth1' I want to echo that it is set to 1 by the cookie to confirm this in the brower through regular html. My if/else statements don't seem to be working though...heres the code I have now. <?php setcookie("bandwidth1","0",time()+2592000,"/"); setcookie("bandwidth2","1",time()+2592000,"/"); setcookie("bandwidth3","2",time()+2592000,"/"); ?> <?php if (isset($_COOKIE["bandwidth1"])=="1") echo "Bandwidth is 1!"; else echo "Bandwidth is unknown"; elsif echo "Cookie was not set?"; ?>
MySQL Conditional Statement
What I am trying to do is kind of like an advanced search. Basically, I have three dropdowns, for this I am going to use the example books: Three dropdowns, which are 1) Author 2) Language 3) Type (Hardback or Paperback) Typical search: I want to get a list of all books written by STEPHEN KING, that are written in ENGLISH and that are HARDBACK ok fine, but what if I just want to search for ALL books by STEPHEN KING regardless of the language or the type of book?? Heres the SQL i would use for all 3 "search parameters": PHP Code:
Writing Conditional Statement
I'm trying write a conditional statement that updates the database in 1 of 2 ways depending on the values given. I'm only 2 weeks into learning PHP/MySQL so I realize the way I've written it out is probably sloppy and more inefficient than what it could be. I've just been winging it from examples and trial and error and have gotten everything working except for this. I'm not sure if I have my logic or syntax wrong. Application-specific details: This is a simple invoicing application. Every invoice is in either 1 of 3 states: - pending (default state when a new invoice is entered) - paid (state when invoice is paid in full) - partial (state when only partial payments have been made on the invoice) What I'm trying to do is this: 1. If a partial payment is made on an invoice, the status is set to 'partial' (this is working) 2. If the payment posted was the full amount of the invoice or the final amount needed to pay it in full, the status is set to 'paid' (this is not working) My processing logic works like this: 1. There is a total invoice amount stored in the invoice table represented by $total variable (working) 2. When payments have been made to that invoice (stored in the payments table), I show the remaining balance on their invoice by calculating the sum of those payments and subtracting them from the total (this is represented by the $diff variable and is working) 3. The part not working: When the remaining balance ($diff) minus the payment amount posted ($_POST['amount']) is equal to 0, the status is set to paid. PHP Code:
Conditional Statements And Loops
Not long ago I was asked to give PHP lections to some private IT school. I'm on second lection now, and will be teaching my :) students conditional statements (if..else and switch) and loops (while and for). That was my story, now the question. Can you give me an advise on some geeky use of those statements to stir up some enthusiasm in students.
Mutlipart And/or Conditional Form
I have a form that needs to have conditional statements, and I am not sure how to "fix" this. The existing form is split in two parts - the form, and the processor. I would think that I will need to combine them, but.. Anyways - what I need is somewhat simple - if a certain option (from a <select>) is chosen, force another field to be completed. I also have 2 other fields that if the radio button is set to YES, require new fields. Ideally, the optional fields would only be shown to the user IF they are required.
Conditional Select From Mysql
I have a mysql database which stores race data that I want to open up to users for viewing. I want the user to be able to select various subsets of the data according to the parameters: race, gender, age, and type (and maybe sometime, by name as well). This is BOTH a mysql question and a php one, as I ask for a more efficient solution (see bottom this post). Here is a snippet of how I am implementing the mysql statements to select only the exact subset of data. PHP Code:
Conditional Preg Match
The following bit of code does a preg match and does something if true (sets $browser to ppcie) Without using if then and else's how do I code it so it does not equal what it is testing for? So if it does not find ppc in the $agent then it does something else/sets it to something else? $agent = getenv("HTTP_USER_AGENT"); if (preg_match("/PPC/i", "$agent")) { $browser = 'PPCIE' }
Question On Conditional Statements
I'm a perl programmer and am trying to learn PHP. So far I have figured out most of the differences, but have not been able to find out how to do the following: When running through a loop, how can you test two separate conditions against the same $element of an array. For example, this is how I thought it would be done (similar to Perl), but it did not work: if (eregi("apple", $line) and (eregi("orange", $line) { do whatever; } Basically testing each line of an array to see if both the words "apple" and "orange" are present. Also, is there any equivalent to the following from Perl while running through a loop: next if (whatever conditions); last if (whatever conditions);
|