How can I add two elements at the same line ?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
chu2654
Forum Newbie
Posts: 11
Joined: Mon Aug 07, 2006 6:59 pm

How can I add two elements at the same line ?

Post 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();
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

How do these methods work?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
chu2654
Forum Newbie
Posts: 11
Joined: Mon Aug 07, 2006 6:59 pm

I use pear HTML_QuickForm

Post by chu2654 »

$form = new HTML_QuickForm('frmMain','post','');

Two selects will show on two lines. May I make it on the same line ?
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post 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.
chu2654
Forum Newbie
Posts: 11
Joined: Mon Aug 07, 2006 6:59 pm

My code

Post 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();

?>
mickd
Forum Contributor
Posts: 397
Joined: Tue Jun 21, 2005 9:05 am
Location: Australia

Post 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.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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();
?>
Post Reply