Click here to Skip to main content
16,008,750 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi there,

I'm currently building some forms and would require some help from you guys as I don't know what to do more ;/.

So:

1. I've tried working with the confirm dialogue box. I am using jformer, a form framework which is quite nice though documentation is lacking information. The form is completely built using classes and functions.

There is the following function on submission.

PHP
function onSubmit($formValues) 
{
$formValues = $formValues->registrationPage->registrationSection1;
							
							$studentID = $formValues->studentid;

etc...
}


Is there a way to insert a javascript confirm on submition is pressed? So that I have a confirmation dialogue and according to which the user pressed (Yes / No) I have an if statement doing what is supposed to do (ie the submission of data / deletion in my case)

2. Triggers in the jformer framework.

I would like to have a drop down list which on click, it shows another drop down list. I have tried the following but only with the use of a checkbox, I have no clue on how to do it with a drop down:

PHP
new JFormComponentMultipleChoice('selectGroup2', '', array(
        						array('value' => 'secondGrp', 'label' => 'Student has second group?'),
            					),
           						array()),
								
     new JFormComponentDropDown('group2', 'Group 2:', $groups2array,
								array(
										'validationOptions' => array('required'),
										'dependencyOptions' => array(
										'dependentOn' => 'selectGroup2',
										'display' => 'hide',
										'jsFunction' => '$("#selectGroup2-choice1").is(":checked");'
										),
							)),	


As you can see from the above, the function checks if the checkbox is checked and is hidden if not checked.

I need a dropdown instead of a checkbox. The first dropdown displays the new drop down showing data according to what the user selected.

I allready found out how to populate the drop down from the database by using the following:
PHP
$query = "SELECT * FROM course";

$resultset = $db->query($query);

$coursearray = array();

array_push($coursearray, array ('value' => '','label' => ' - Select an Option - ','selected' => true));	

while ($row = mysql_fetch_array($resultset))
	{	
		array_push($coursearray, array ('value' => $row["course_ID"], 'label' => $row["course_Name"],));  
	}


after the array is populated, I use the following to populate the dropdown:

PHP
new JFormComponentDropDown('course', 'Course:', $coursearray,
							array(							
								'validationOptions' => array('required')
							),
							array(
								'tip' => '<p>Select Course</p>',
							)),


I know I am asking a bit more then I should but I tried almost everything I could and spent days of research on how certain stuff works. Your help is much appreciated and I would donate something small to whom helps me find a solution to these!

Thanks,
Francesco
Posted
Updated 4-Feb-12 6:49am
v3

1 solution

If the code you showed is PHP, by the time this is called, it's too late to show something to the client to confirm. I've never used this framework, and I suspect most people here are the same ( most people here would use more modern tools than PHP, although we probably nearly all use jquery ). So, I'd suggest looking for a forum dedicated to this framework, or you can use Chrome to step through your javascript code, which means you can step in to the library itself to see if it's doing anything that leaves room for what you want it to do ( or you can even change the library to allow what you want ).
 
Share this answer
 
Comments
Necron8 6-Feb-12 12:47pm    
Yeah I think it's a fair deal. So what languages are being used that are better then PHP?

Thanks for the tip :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900