Page 1 of 1

How can I add two elements at the same line ?

Posted: Sun Aug 27, 2006 8:43 pm
by chu2654
Hello, The following code will add the two elements at different lines. How can I add elements at the same line ?

$form->addElement('date','from',Null,$options);
$form->addElement('date','to'," ~ ",$options);
$form->Display();

Posted: Sun Aug 27, 2006 8:44 pm
by RobertGonzalez
How do these methods work?

Posted: Sun Aug 27, 2006 9:15 pm
by feyd
Swami says: can't tell, need more information.

...like, oh, what you're using; more code; what the output is... you know, the little details.

I use pear HTML_QuickForm

Posted: Sun Aug 27, 2006 9:41 pm
by chu2654
$form = new HTML_QuickForm('frmMain','post','');

Two selects will show on two lines. May I make it on the same line ?

Posted: Sun Aug 27, 2006 9:42 pm
by RobertGonzalez
Ok, can you please post code. Little nibbles like that will get you nowhere fast. If we can't see what the code is doing we cannot help you with your problem.

My code

Posted: Mon Aug 28, 2006 1:37 am
by chu2654
May I add the two select element as the same line ?

<?php

require_once "HTML/QuickForm.php";
$form = New HTML_QuickForm();
$options = array( 'language' => 'en',
'format' => "Y-m-d",
'minYear' => 2002,
'maxYear' => 2006);
$form->addElement('date','from',Null,$options);
$form->addElement('date','to',Null,$options);
$form->display();

?>

Posted: Mon Aug 28, 2006 1:40 am
by mickd
It is probably safe enough to assume he is using PEAR's HTML_QuickForm package. Unfortunately, i have no prior experience with that myself.

Posted: Mon Aug 28, 2006 4:11 am
by volka
It's e.g. possible by grouping the elements

Code: Select all

<?php
require_once "HTML/QuickForm.php";
$form = New HTML_QuickForm();

$options = array(
		'language' => 'en',
		'format' => "Y-m-d",
		'minYear' => 2002,
		'maxYear' => 2006
	);


$form->addElement('group', 'myGroup',
		array('period') /* element label(s) */,
		array( /* elements */
				HTML_Quickform::createElement('date', 'from', null, $options),
				HTML_Quickform::createElement('date', 'to', null, $options)
			),
		array( ' till ') /* separator */
	);
$form->display();
?>