radio button in php

  • conn2prince
  • Graduate
  • Graduate
  • User avatar
  • Joined: Jun 28, 2005
  • Posts: 119
  • Status: Offline

Post August 24th, 2005, 9:58 pm

i am having 3 radio buttons in my phpform.what i need is when i click the first radiobtn i shld get the first phpform,wen i click the second i shld get the second phpform and for the third another phpform.how can i do everything in a single php page.the other thing is that the three php forms are having submit buttons too.
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post August 24th, 2005, 9:58 pm

  • Tannu4u
  • Proficient
  • Proficient
  • User avatar
  • Joined: Apr 29, 2004
  • Posts: 455
  • Loc: India
  • Status: Offline

Post August 24th, 2005, 10:09 pm

You can do it with the help of Javascript and making three different forms. There is a style property of the <TR> Tag that u can use to hide the forms.

style="display:none"

hides the tr from showing on the form

and

style="display:"

shows the tr on the form.


This can also be handeled with javascript.
On the click of the radio button u can change the display of the <tr> tag.

Hope u got it. If u need me further i am here.
Amit
My Blog http://www.amityadav.name
  • conn2prince
  • Graduate
  • Graduate
  • User avatar
  • Joined: Jun 28, 2005
  • Posts: 119
  • Status: Offline

Post August 24th, 2005, 10:15 pm

can u explain with a piece of code....bcoz i am not much familiar with js
  • camp185
  • Graduate
  • Graduate
  • User avatar
  • Joined: Aug 22, 2005
  • Posts: 214
  • Loc: San Jose, CA
  • Status: Offline

Post August 24th, 2005, 10:23 pm

Try something like this

First create the form to select the active form of the users choice.

<form method="POST" action="linktoself.php" name="formselector">
<select size="1" name="formselector" onchange=citystat.submit()>
<option value="form1_on">form1</option>
<option value="form2_on">form2</option>
<option value="form3_on">form3</option>
</select>
</form>

Then somewhere before the other forms have an if clause like
if ($formselector=="form1_on")
{
echo "Form1 html";
}
if ($formselector=="form2_on")
{
echo "Form2 html";
}

and so on to 3.

Not the exact answer, but the logic is there I think.
Subscribe to my full feed RSS for Usability Tips and Site Reviews
Get My Basic Usability & Design Analysis
  • conn2prince
  • Graduate
  • Graduate
  • User avatar
  • Joined: Jun 28, 2005
  • Posts: 119
  • Status: Offline

Post August 24th, 2005, 10:30 pm

when i post the data from any of the form(form1,form2,...) i shld be able to get the radio buttons value too...if i am using ur code then i dont think i can get it....bcoz it is out of the form
  • camp185
  • Graduate
  • Graduate
  • User avatar
  • Joined: Aug 22, 2005
  • Posts: 214
  • Loc: San Jose, CA
  • Status: Offline

Post August 24th, 2005, 11:19 pm

Just include this in form:

<input type="hidden" name="yourradiobutton" value="valueof radiobutton">
Subscribe to my full feed RSS for Usability Tips and Site Reviews
Get My Basic Usability & Design Analysis
  • conn2prince
  • Graduate
  • Graduate
  • User avatar
  • Joined: Jun 28, 2005
  • Posts: 119
  • Status: Offline

Post August 24th, 2005, 11:25 pm

where i shld add this.whether in the main page or in all other pages
  • camp185
  • Graduate
  • Graduate
  • User avatar
  • Joined: Aug 22, 2005
  • Posts: 214
  • Loc: San Jose, CA
  • Status: Offline

Post August 24th, 2005, 11:48 pm

Not sure what you mean there, but the input goes between the form tags
Subscribe to my full feed RSS for Usability Tips and Site Reviews
Get My Basic Usability & Design Analysis
  • conn2prince
  • Graduate
  • Graduate
  • User avatar
  • Joined: Jun 28, 2005
  • Posts: 119
  • Status: Offline

Post August 24th, 2005, 11:59 pm

Code: [ Download ] [ Select ]
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>



<form name="frmSearch" method="post" action="search/results.php">
  <table width="98%" border="0">

  <tr>
   <td colspan="3" class="v01"><input name="rdbtn" type="radio" value="A" checked>
    Car
    <input type="radio" name="rdbtn" value="B" onClick="go('b.php');">
    Bike
    <input type="radio" name="rdbtn" value="C" onClick="go('c.php');">
    Others</td>
  </tr>
  <tr>
   <td class="v01"> <a href="advancedcsearch.php">advanced search</a></td>
   <td width="50%">
    <input type="submit" name="Submit" value="Search">
    </td>
  </tr>
  <input type="hidden" name="search" value="normal">
 </table>
</form>




</body>
</html>
  1. <html>
  2. <head>
  3. <title></title>
  4. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  5. </head>
  6. <body>
  7. <form name="frmSearch" method="post" action="search/results.php">
  8.   <table width="98%" border="0">
  9.   <tr>
  10.    <td colspan="3" class="v01"><input name="rdbtn" type="radio" value="A" checked>
  11.     Car
  12.     <input type="radio" name="rdbtn" value="B" onClick="go('b.php');">
  13.     Bike
  14.     <input type="radio" name="rdbtn" value="C" onClick="go('c.php');">
  15.     Others</td>
  16.   </tr>
  17.   <tr>
  18.    <td class="v01"> <a href="advancedcsearch.php">advanced search</a></td>
  19.    <td width="50%">
  20.     <input type="submit" name="Submit" value="Search">
  21.     </td>
  22.   </tr>
  23.   <input type="hidden" name="search" value="normal">
  24.  </table>
  25. </form>
  26. </body>
  27. </html>


currently my php form is like this.please tel me camp185 how to make use of ur code with this existing one.
  • camp185
  • Graduate
  • Graduate
  • User avatar
  • Joined: Aug 22, 2005
  • Posts: 214
  • Loc: San Jose, CA
  • Status: Offline

Post August 25th, 2005, 12:18 am

conn2prince wrote:
[code]


<tr>
<td colspan="3" class="v01"><input name="rdbtn" type="radio" value="A" checked>
Car
<input type="radio" name="rdbtn" value="B" onClick="go('b.php');">
Bike
<input type="radio" name="rdbtn" value="C" onClick="go('c.php');">
.


I think the problem is here...it looks like you created 3 pages for 3 forms, a,b, and c. You should just have all of the forms on one page, and then echo the right one when onClick value tells it which one..

using the 3 same input types... don't link to a.php, b.php, c.php, but to samepage.php?value=showforma,b, or c.

You'll hack it out. It's kind of hard to know exactly what you mean and exactly what I mean.
Subscribe to my full feed RSS for Usability Tips and Site Reviews
Get My Basic Usability & Design Analysis

Post Information

  • Total Posts in this topic: 10 posts
  • Users browsing this forum: PolishHurricane and 205 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© Unmelted Enterprises 1998-2009. Driven by phpBB © 2001-2009 phpBB Group.