Forums

I have a problem with php code on V5.

Ron 05 Mar, 2014
Hello

I have a problem running this code on my V5 form. I had to regenerate this code as I had lost this code. Would someone please pinpoint the fault.

I am trying to make the radio button "required" but I am not able to make it work. The code is below.

$available_options = array("exw"=>"<font color='RED'><b>1.</b></font><b>Ex-Works.(EXW)<b/><font color='RED'> ==> </font> ",
                           "fob"=>"<font color='RED'><b>2.</b></font><b>Free on Board.(FOB)<b/><font color='RED'> ==> </font>",
                           "cfr"=>"<font color='RED'><b>3.</b></font><b>Cost and Freight.(CFR)<b/><font color='RED'> ==> </font>",
                           "cif"=>"<font color='RED'><b>4.</b></font><b>Cost Insurance Freight.(CIF)<b/><font color='RED'> ==> </font>",
                           "other"=>"<font color='RED'><b>5.</b></font><b>Other mode<b/><font color='RED'> ==> </font>",
                          );
if ($_GET["cref"]=="exw") echo "checked=\"checked\"";
if ($_GET["cref"]=="fob") echo "checked=\"checked\"";
if ($_GET["cref"]=="cfr") echo "checked=\"checked\"";
if ($_GET["cref"]=="cif") echo "checked=\"checked\"";
if ($_GET["cref"]=="other") echo "checked=\"checked\"";

if (strlen($processing_message) > 0) {
  echo '<div class="processing_message">'.$processing_message.'</div>';
}
echo '<form method="post" action="'.basename(__file__).'">';
foreach($available_options as $option_value=>$option_label) {
  //Notice the use of the ternary operator ()?: to check the selected radio button after the form was submitted.
  echo $option_label.'<input type="radio" style="font-family:Verdana, Geneva, sans-serif; font-size:15px; border:1px solid #999;" name="option_choice" required value="'.$option_value.'" '.(($option_value == $_POST['option_choice'])?' checked="checked"':'').'/><br><br>';
    if (empty($_GET) === false) {
        $available_options = array('exw', 'fob', 'cfr', 'cif');
        foreach ($_GET as $key=>$value) {
            if (empty($value) && in_array($key, $available_options) === true) {
                $errors[] = 'You didn\'t select the type of price quote.';
                break 1;
            }
        }
    }
    print_r($errors);
   
  
}
echo '<input type="submit" class="submitbtn" value="Proceed" style="font-family:Verdana, Geneva, sans-serif; width:180px; height:40px; font-size:20px;" />';
echo '</form>';


Thanks for any possible help.

Ronn
Ron 07 Mar, 2014
Hi,
I was wondering if someone saw my post ??

Best wishes

Ron
Ron 07 Mar, 2014
I did this but still it does not make the radio button required.
$available_options = array("exw"=>"<font color='RED'><b>1.</b></font><b>Ex-Works.(EXW)<b/><font color='RED'> ==> </font> ",
                           "fob"=>"<font color='RED'><b>2.</b></font><b>Free on Board.(FOB)<b/><font color='RED'> ==> </font>",
                           "cfr"=>"<font color='RED'><b>3.</b></font><b>Cost and Freight.(CFR)<b/><font color='RED'> ==> </font>",
                           "cif"=>"<font color='RED'><b>4.</b></font><b>Cost Insurance Freight.(CIF)<b/><font color='RED'> ==> </font>",
                           "other"=>"<font color='RED'><b>5.</b></font><b>Other mode<b/><font color='RED'> ==> </font>",
                          );
if ($_GET["cref"]=="exw") echo "checked=\"checked\"";
if ($_GET["cref"]=="fob") echo "checked=\"checked\"";
if ($_GET["cref"]=="cfr") echo "checked=\"checked\"";
if ($_GET["cref"]=="cif") echo "checked=\"checked\"";
if ($_GET["cref"]=="other") echo "checked=\"checked\"";

if (strlen($processing_message) > 0) {
  echo '<div class="processing_message">'.$processing_message.'</div>';
}
echo '<form method="post" action="'.basename(__file__).'">';
foreach($available_options as $option_value=>$option_label) {
  //Notice the use of the ternary operator ()?: to check the selected radio button after the form was submitted.
echo $option_label.'<input type="radio" required="true" style="font-family:Verdana, Geneva, sans-serif; font-size:15px; border:1px solid #999;" name="option_choice" required value="'.$option_value.'" '.(($option_value == $_POST['option_choice'])?' checked="checked"':'').'/><br><br>';
}
echo '<input type="submit" class="submitbtn" value="Proceed" style="font-family:Verdana, Geneva, sans-serif; width:180px; height:40px; font-size:20px;" />';
echo '</form>';


Please help

Ron
GreyHead 08 Mar, 2014
Hi Ronn,

I saw your post but I don't see what it has to do with ChronoForms?

Bob
Ron 08 Mar, 2014
Thanks for your reply Bob,

I have a custom form that give out a confirmation before executing another custom code. It was working fine in V4 but it does not seem to work in V5 that I have updated.

Since you know the V5 would you please suggest where I may be going wrong ?

Thanks again and Best wishes

Ron
GreyHead 08 Mar, 2014
Hi Ronn,

This is some rather odd custom HTML+ PHP that includes it's own form tags so can't submit to ChronoForms. I'm afraid that you get the pleasure of debugging your own custom code.

Bob
Ron 13 Mar, 2014
Thanks for the reply. I have managed to solve this issue. The php code displays a html form.

best wishes

Ronn
This topic is locked and no more replies can be posted.