473,383 Members | 1,716 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

view result when select one radio button

i have php page with 4 radio buttons and text box if user chose first two radio buttons then the next page need to display the results depending which radio buttons select but other two depend on value on textbox entered then spefic fields should be shows but i have no idea how to do that
how can i get radio buttons
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.   require_once("nocache.php");
  3.   session_start();
  4. if (!$_SESSION["who"]){
  5. header ("location:logoff.php");}
  6.   ?>
  7.  <?xml version="1.0" encoding="UTF-8"?>
  8. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  9.   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
  10.  
  11. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  12.  
  13. <head>
  14.     <title>selectview.php</title>
  15. </head>
  16. <body>
  17. <form  name="form1" method="post" action="viewList.php">
  18. <h1> APPLICATION SEARCH </h1>
  19. <?php echo $_SESSION["name"] ;?><br/>
  20. <?php echo $_SESSION["level"] ;?> 
  21. <p> <a href="logoff.php"> logoff </a> </p>
  22. <p> What do you want to do next? <br/>
  23. <input type="radio" name="staff"  value="Once"  onfocus="disableField()" />To Be Processed<br/>
  24. <input type="radio" name="staff" value="twice" onfocus="disableField()" />Processed <br/>
  25. <input type="radio" name="staff" value="three" onfocus="enableField()" > Search By Student ID<br/>
  26. <input type="radio" name="staff"  value="four" onfocus="enableField()"  /> Search By Application Number </p>
  27. <script language="javascript">
  28.  
  29. function enableField()
  30. {
  31. document.form1.search.disabled=false;
  32. }
  33.  
  34. function disableField()
  35. {
  36. document.form1.search.disabled=true;
  37.  
  38. }
  39.  
  40.  
  41. </script>
  42.  
  43. <p> Enter your search here <input type="text" name="search" disabled="true"  /></p>
  44.  
  45. <p> <input type="submit" value="Finshed " />
  46.   <input type="reset"  value="Reset"/></p> 
  47.     <?php
  48. echo date("d/m/Y") ;
  49. ?> 
  50.    </form>
  51. </body>
  52. </html>
  53.  
May 20 '09 #1
1 3098
hoopy
88
You need to check using either an IF or SWITCH scenario on what button was selected and act accordingly. For example:

Expand|Select|Wrap|Line Numbers
  1. <?
  2. if($_POST['staff'] == "Once")
  3. {
  4.   // 1st button was selected
  5. } elseif($_POST['staff'] == "Twice") {
  6.   // 2nd button was selected
  7. } else {
  8.   // 3rd of 4th button has been selected
  9.   $search = $_POST['search'];
  10.   // do something here with the search data
  11. }
  12. ?>
You could alternatively use a switch check like this:

Expand|Select|Wrap|Line Numbers
  1. <?
  2. switch($_POST['staff'])
  3. {
  4.   case 'Once':
  5.   // 1st button was selected do something
  6.   break;
  7.  
  8.   case 'Twice':
  9.   // 2nd button was selected do something
  10.   break;
  11.  
  12.   default:
  13.   // 3rd of 4th button has been selected
  14.   $search = $_POST['search'];
  15.   // do something here with the search data
  16.   break;
  17. }
  18. ?>
Cheers.
May 20 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Arun Nair | last post by:
Hi, I have the following jsp page. I am able to view only a part of it(until the occurence of the first City text box). If i remove the first few fields from the page, I am able to see a few...
12
by: Neil | last post by:
I previously posted re. this, but thought I'd try again with a summary of facts. I have an Access 2000 MDB with a SQL Server 7 back end. There is a view that is linked to the database via ODBC...
3
by: Alpha | last post by:
I have 3 radio buttons for include, exclued or 'select all' from the listbox items. If a user selects the 'Select All' button' then all items in listbox is hi-lited as selected. Now, when user...
6
by: Robert W. | last post by:
I'm building my first major C# program and am try to use best practices everywhere. So I've implemented the "Document/View Model" whereby: - There's a Windows Form, which we'll call "formView" -...
5
by: Dan | last post by:
Hi, I'm going crazy here, please help. I have a parent page that has a user control on it that bubbles up data from a dropdown menu. The drop down menus are populated by a set of radio buttons,...
2
by: tpaulson | last post by:
I have a couple of DIV's that I hide/display based on radio buttons. On the DIV's, I have multiple drop down boxes. The source shows that they are populated, but I can't make them drop down. Only...
11
by: bill | last post by:
I dynamically create buttons and associate them with an event using AddHandler. I want all the button events to fire at one time, when the page is posted, instead of when each button is clicked....
4
by: patelxxx | last post by:
Currently when I select one of the radio buttons and then press submit, the answer which is alerted is always 'false', even if i press 'true', I still get 'false' alerted. What I'm i doing wrong?...
10
by: mukeshrasm | last post by:
Hi I have a html in which there is two selection box and two radio button. Radio buttion is of array type. What I want if user will click the radio button then only he/she be able to make...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.