• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 199
  • Last Modified:

PHP Form Script (2) with MySQL

I am creating a webform and have a question about setup. The advisor using the form has to go through a checklist with departing students. There are a number of checkboxes that are dependent on each other I am trying to figure out how to code to the webform. For example the advisor has to check whether or not they asked the student about the status of their ID Card. They then have to check if they were able to collect it or not. So basically you have a checkbox for "ID Card" and a radio button to check either "Collected" or "Not Collected". The form is incomplete and should not be submitted without this information. There is some reverse logic here too. If the advisor selects one of the two radio buttons, the checkbox would automatically get a check because by signifying it has been either collected or not collected by default the advisor would have had to ask. That being said there should be no preset default setting for the radio buttons. So, can anybody help me set this up by putting the PHP code within an HTML table?
0
bpfsr
Asked:
bpfsr
1 Solution
 
rtuplinCommented:
Having dependability between HTML form items would fall to Javascript rather than PHP as its client side, not server side.

If you wanted to check what a tick box or radio button was once the form was submitted, then yes, this can be done with PHP.  However, getting the radio button to automatically tick the ticket box is pure javascript, so you may be better off asking the question on the javascript board.
0
 
houssam_balloutCommented:
Well, doing that so in php is much better because some browsers may had been disable JavaScript.
For example to see where a checkbox has been enabled in php use:


<?php
//VariablaName is the name of the checkbox
if(isset($_POST['variableName']))
{
//If it has been checked then set the variable to true
$myVar = 'true';
//and here you can also set the radio button to on also
 
 
}
 
 
?> 

Open in new window

0
 
Loganathan NatarajanLAMP DeveloperCommented:
you may check each and every form field  (check boxes) value ... whether it is empty or checked... if it is empty just have default value (0 or 1) to the variables ... so the problem will be solved...

as **rtuplin** said, it could be done very well using Javascript after validating the form... or while submitting the form
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now