Download .zip |
Info | View files (4) | Download .zip | Reputation | Support forum | Blog | Links |
Last Updated | Ratings | Unique User Downloads | Download Rankings | |||||
2012-05-17 (6 years ago) | Not yet rated by the users | Total: 627 | All time: 4,906 This week: 552 |
Version | License | PHP version | Categories | |||
form-generation 1.0 | GNU General Publi... | 5.2 | HTML |
Description | Author | ||||||||||||||
This class can create HTML forms using jQuery for validation. |
|
This class is used to create html forms with validation. To use, in the head(html): <script language="JavaScript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> <script language="JavaScript" src="validation.js"></script> <script language="JavaScript"> var valid = new validate(); </script> To setup the class: <?php include('formgeneration.php'); // load the class $vf = new formgeneration('valid'); // The name of the javascript class is passed in ?> Check the example index.php for an example of creating a child class that extends this class To create the form(html): <?php echo $vf->open_form()."\n"; ?> To close the form: <?php echo $vf->close_form()."\n"; ?> To create a label: <?php echo $vf->create_label('Name of object', 'Label')."\n"; ?> To create a textbox: <?php echo $vf->create_text('name', 'required')."\n"; ?> Textarea: <?php echo $vf->create_textarea('name', 'required', rows, columns)."\n"; ?> Checkbox: <?php echo $vf->create_Check('name')."\n"; ?> Select List: <?php $values = array( '' => 'Please Select', '1' => 'Option 1', '2' => 'Option 2', '3' => 'Option 3', ); echo $vf->create_select('name', 'required', $values)."\n"; ?> Radio button group: <?php $values = array( 'Milk' => 'Milk', 'Butter' => 'Butter', 'Cheese' => 'Cheese', ); echo $vf->create_radio_group('name', 'required', $values)."\n"; ?> Post submit processng. The set up is the same for the form. I use the following to redirect back to the input form on a validation error. <?php // post submit processing, normally done on thetarget page though one could useredirects if (isset($_POST['submit'])) { $error = $vf->validate(); if ($error != '') { // do validation error proccessing unset ($_POST['submit']); // we don't want this in the post data going back to the original form ?> <form name="submision_form" id="submision_form" method="POST" action="/"> <?php echo $vf->savePostGet(); ?> <input type="hidden" name="Message" value="<?php echo $error; ?>"> </form> <script type="text/javascript"> $(document).ready(function() { alert ('<?php echo $error; ?>'); $("#submision_form").submit(); }); </script> <?php exit; // redirect back to the original page } else { // Save the data or whatever } } ?> |
Files |
File | Role | Description |
---|---|---|
formgeneration.php | Class | formgeneration class file |
index.php | Example | Demonstration Script |
readme.txt | Doc. | Dovumentation |
validation.js | Data | Validation jQuery class |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
0% |
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.