FireFox! The PHP Forum Loans and Credit
Panama Web Design for Hire Free Insurance Quotes!
Web Hosting Advertise Here $10 a Month Designer Children
Never Pay Taxes Again HGH Domain name registration
Web Hosting and Dedicated Servers Insurance Affordable web-hosting


HomeWatched TopicsRegisterSearchDirectory
FAQMemberlistUsergroupsLog inStoresItemsBank
Google

Reply to topic Page 1 of 1
Runtime Validation
Message  

Reply with quote
Post Runtime Validation 
Hi Gurus!

I wana do some runtime validation. For example, i have a form with some check boxes.
like :

Select Toys Cat: Airoplanes checkbox1, Cars checkbox2

if someone checks airoplanes then

all different types of airoplanes names should come in a multiple selection listbox below in the following format.
Suppose:

Selected toys : fighter plane
                      resuce plane
                      passenger plane etc.....

Any idea! How can i do this thing.

If this thing was to be done in a software like Vb.net etc then it was a piece of cake, i m wondering how can i do such thing in php???

View user's profile Send private message

Reply with quote
Post  
Hi, sorry for not replying. Have been a little busy.

You can do that both in javascript and in PHP. In PHP it would look like this:

Code:


<?php
if(isset($_POST['transport']))
{
 if($_POST['transport']=='airplanes')
 {
  echo '
  <form action="index.php" method="post">
  <select name="categories">
  <option value="fighter plane">Fighter plane</option>
  <option value="resuce plane">Resuce plane</option>
 </select><br /><br /><input type="submit" value="submit">';
 }
 elseif($_POST['transport']=='cars')
 {
   echo '
  <form action="index.php" method="post">
  <select name="categories">
  <option value="Van">Van</option>
  <option value="Truck">Truck</option>
 </select><br /><br /><input type="submit" value="submit">';
 }
}
else
{
 echo '<form action="index.php" method="post">
<input type="radio" name="transport" value="airplanes"> Airplanes<br />
<input type="radio" name="transport" value="cars"> Cars <br /><br />
<input type="submit" value="submit">
</form>';
}
?>


And in javascript it would look like this:

Code:

<script language="javascript">
var selectB='<select name="categories">';
var selectE='</select>';
function changeOptions()
{
 var setOption=document.transportForm.transport.value;
 var options='';
 if(setOption=='airplanes')
  options='<option value="fighter plane">Fighter plane</option><option value="resuce plane">Resuce plane</option>';
 else if(setOption=='cars')
  options='<option value="Van">Van</option><option value="Truck">Truck</option>';
 document.getElementById('selectsId').innerHTML=selectB+options+selectE;
}
</script>
<form action="index.php" method="post" name="transortForm">
<input type="radio" name="transport" value="airplanes" onclick="changeOptions()"> Airplanes<br />
<input type="radio" name="transport" value="cars" onclick="changeOptions()"> Cars <br />
<div id="selectsId"></div><br /><br />
<input type="submit" value="submit">
</form>


Should be working )))). Have fun,
Pratamishus.


_________________
www.eb-downloads.com
FREE E-BOOKS DOWNLOADS.
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
Display posts from previous:
Reply to topic Page 1 of 1
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 vote in polls in this forum
  



Google

FireFox! The PHP Forum Loans and Credit
Panama Web Design for Hire Free Insurance Quotes!
Web Hosting Advertise Here $10 a Month Designer Children
Never Pay Taxes Again HGH Domain name registration
Web Hosting and Dedicated Servers Insurance Affordable web-hosting


Web Design by PlatinumShore.com & Web Hosting by TradeWebHosting.com