0

I have this form which has 2 radio buttons. If I select the radio button labeled as one way, the return date and time will be invisible; if I select return, the return date and time will be visible. I just want to test if the data have been entered when oneway is selected. This is because when I select return, I can print out all the input values by user, but if I select oneway, I can't do so.

This is the code I am using.

echo "<h1>Booking</h1>";
$submit = $_POST['submit'];

if ($submit) {  
  // Check the direction selected by user.
  if ($direction == "return") {
    if ($liner && $direction && $from && $f_date && $f_time && $destination && $t_date && $t_time && $txttotal) {
      echo "$liner/$direction/$from /$f_date/$f_time/ $destination/$t_date/$t_time/$txttotal  ";
    }
  }
}
2
  • You should show the code you are using; otherwise, answering it will not be so easy.
    – apaderno
    May 8, 2013 at 13:46
  • Just to be sure: Is this a question about Drupal? It is not the kind of code you should use for Drupal, especially because it doesn't use the form API.
    – apaderno
    May 8, 2013 at 17:16

2 Answers 2

0

In the Drupal Examples project you can find the ajax_example module with a similar form with dependent fields.

http://drupal.org/project/examples

0

Please use the Drupal form API -- http://api.drupal.org/api/drupal/developer%21topics%21forms_api_reference.html/7

You should almost never use the $_POST / global PHP variables in Drupal communications as they are not sanitized.

To handle submitted content you should be using hook_form_submit(). The Devel module http://drupal.org/project/devel is very helpful in debugging / figuring out what data you are passing back and forth for processing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.