81
phillipd
Re: Is there a way to...
  • 2004/11/11 15:26

  • phillipd

  • Quite a regular

  • Posts: 219

  • Since: 2004/4/20


If you mean:

while(list($id,$status,$name) = $xoopsDB->fetchRow($result)) {
$select_defaults->addOption($name,$name);
$select_defaults->setValue($status);
echo "$status-";
}

$tray_defaults->addElement($select_defaults);

It made no difference.

Am I using setValue correctly? Will it set the value just for the option I just added? If I do a $select_defaults->setValue(0) below the "while" loop all the entries in the select list get highlighted. This would indicate I can't highlight an individual element in the list.

Doug P



82
phillipd
Re: Is there a way to...
  • 2004/11/11 7:04

  • phillipd

  • Quite a regular

  • Posts: 219

  • Since: 2004/4/20


I'm doing this (Below) and I have the "status" column of the db set to 1's where I want the item selected but it doesn't seem to select any of the formselect items:

$select_defaults = new XoopsFormSelect("","defaults","","29",true);
$tray_defaults = new XoopsFormElementTray(_MM_LAYERS, " ");
$tray_defaults->addElement($select_defaults);

$sql = 'SELECT id,status,name FROM '.$xoopsDB->prefix('gis_layers').' ORDER BY id';
$result = $xoopsDB->query($sql);

while(list($id,$status,$name) = $xoopsDB->fetchRow($result)) {
$select_defaults->addOption($name,$name);
$select_defaults->setValue($status);
echo "$status-";
}


DB table looks like:

mysql> describe xoops_gis_layers;
+--------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------+------------------+------+-----+---------+----------------+
| id | int(15) unsigned | | PRI | NULL | auto_increment |
| status | varchar(255) | | | 1 | |
| name | varchar(255) | | | | |
+--------+------------------+------+-----+---------+----------------+
+----+--------+------------------------------+
| id | status | name |
+----+--------+------------------------------+
| 1 | 0 | Locale |
| 2 | 0 | Buildings |
| 3 | 0 | Businesses |
| 4 | 0 | Institutions |
| 5 | 0 | Physicians |
| 6 | 0 | Hospitals |
| 7 | 0 | Recreation Area |
| 8 | 0 | Petroleum Facilities |
| 9 | 0 | Petroleum Interconnects |
| 10 | 0 | Transmission Lines |
| 11 | 0 | Hydroelectric Plant |
| 12 | 0 | Power Plants |
| 13 | 0 | Electric Substations |
| 14 | 0 | NRC Facilities |
| 15 | 1 | Highways |
| 16 | 0 | Streets (Local) |
| 17 | 0 | Streets |
| 18 | 1 | Railroads |
| 19 | 1 | Rivers and Streams |
| 20 | 0 | Pipelines |
| 21 | 0 | DOE Site Buildings |
| 22 | 0 | DOE Areas |
| 23 | 0 | NRC Emergency Planning Zones |
| 24 | 0 | Zip Code (area) |
| 25 | 0 | Counties |
| 26 | 0 | DOE. Sites |
| 27 | 0 | Parks |
| 28 | 0 | Landmarks |
| 29 | 0 | Airports |
| 30 | 0 | Major Water |
| 31 | 1 | Lakes and Reservoirs |
| 32 | 0 | Urban Places |
| 33 | 0 | Federal Land (areas) |
| 34 | 1 | States |
| 35 | 1 | Countries |
| 36 | 1 | Oceans |
+----+--------+------------------------------+

Thanks

Doug P



83
phillipd
Re: Is there a way to...
  • 2004/11/11 6:40

  • phillipd

  • Quite a regular

  • Posts: 219

  • Since: 2004/4/20


The checkboxes appear to be too problematic because I can only get the selected ones so I have decided to try a XoopsFormSelect. This doesn't suffer from the same problem I hope. My recieving script should be able to iterate through the the whole select list I hope and discover the state of each item in the list???

After creating the xoopsformselect How do you programatically select items in the list (without clicking them)?

What does setvalue() do? What "value" am I setting?

What does getvalue() do? What "value am I getting?


Thanks

Doug P



84
phillipd
New explanation of problem
  • 2004/11/10 5:12

  • phillipd

  • Quite a regular

  • Posts: 219

  • Since: 2004/4/20


I have lots of checkboxes to display, each with a different label, in a row and column format. I've got the row and column problem solved but I want to get away from having to do the standard 3 or 4 lines of code to do each checkbox like this:

$tray_locale = new XoopsFormElementTray("");
$locale = new XoopsFormCheckBox("","Locale",!$opt[$i++]);
$locale->addOption("0","Locale");
$tray_locale->AddElement($locale);

$tray_buildings = new XoopsFormElementTray("");
$buildings = new XoopsFormCheckBox("","Buildings",!$opt[$i++]);
$buildings->addOption("0","Buildings");
$tray_buildings->AddElement($buildings);

$tray_Businesses = new XoopsFormElementTray("");
$Businesses = new XoopsFormCheckBox("","Businesses",!$opt[$i++]);
$Businesses->addOption("0","Businesses");
$tray_Businesses->AddElement($Businesses);

... up to 40 or so checkboxes.

I would like to put the name of each checkbox in a DB table and create them on the fly into a template like this:

$sql = 'SELECT name FROM '.$xoopsDB->prefix('gis_checkbox').'';
$result = $xoopsDB->query($sql);
$i = 0;
//$check = array();
$testform = new XoopsThemeForm("", "testform", "setlayers.php");

while (list($name) = $xoopsDB->fetchRow($result)) {
$tray = new XoopsFormElementTray("");
$check = new XoopsFormCheckBox("",$name,"0");
$check->addOption("0",$name);
echo "$name";
$tray->addElement($check);
$testform->addElement($tray);
}


The trouble is I can't figure out how to read them after they are posted in my form because there really is no "handle" to post. "$check" is used over and over to create all the checkboxes, so I can't use it.

Any suggections are greatly appreciated.

Doug P



85
phillipd
What is the purpose of passng an array of strings to xoopsformcheckbox?
  • 2004/11/10 4:51

  • phillipd

  • Quite a regular

  • Posts: 219

  • Since: 2004/4/20


What is the purpose of passing an array of strings in the constructor of a XoopsFormCheckBox? What does the checkbox display?


Thanks

Doug P



86
phillipd
Re: Is there a way to...
  • 2004/11/10 3:42

  • phillipd

  • Quite a regular

  • Posts: 219

  • Since: 2004/4/20


I got a nicely formatted (rows and columns) set of checkboxes like this but now how do I read them after posting the form?

PHP:

$sql = 'SELECT name FROM '.$xoopsDB->prefix('gis_checkbox').'';
$result = $xoopsDB->query($sql);
list($opt) = $xoopsDB->fetchRow($result);

$testform = new XoopsThemeForm("", "testform", "setlayers.php");
while (list($name) = $xoopsDB->fetchRow($result)) {
$tray = new XoopsFormElementTray("");
$check = new XoopsFormCheckBox("",$name,0);
$check->addOption("0",$name);
$tray->addElement($check);

$testform->addElement($tray);

}
$testform->assign($xoopsTpl);
$xoopsTpl->display('db:'.$xoopsOption['template_main']);

Template:

<{$testform.javascript}>
<b><{$testform.title}></b>
<form name="<{$testform.name}>" action="<{$testform.action}>" method="<{$testform.method}>" <{$testform.extra}>>
<table class="outer" cellpadding="4" cellspacing="1">
<tr>
<{counter assign=elementno start=0 print=false}>
<{foreach item=element from=$testform.elements}>
<{if $elementno % 4 == 0}>
<tr></tr>
<{/if}>
<td class="<{cycle values="even,odd"}>"><{$element.body}></td>
<{counter}>
<{/foreach}>
</tr>
</table>
</form>



87
phillipd
Is there a way to...
  • 2004/11/10 2:08

  • phillipd

  • Quite a regular

  • Posts: 219

  • Since: 2004/4/20


I've created a matrix of checkboxes with standard Smarty code, 26 of them to be exact. As our GIS people add more and more data and layers to the database I have to add more checkboxes. It's rather time consuming to add more and I'd like to try to put the checkbox names and handles in a DB table and create the array as I iterate through a result set from a DB query.

1) Is it possible to put things like XOOPS checkboxes in an array? If so how is the assignment done?

2) If item one is possible, Can I then pass the array of checkboxes to smarty and iterate through it in a template as I do an array of strings?

Thanks

Doug P



88
phillipd
What determines the display order of the icons in the Admin Menu
  • 2004/11/4 22:37

  • phillipd

  • Quite a regular

  • Posts: 219

  • Since: 2004/4/20


I would like to raise my modules Icon higher on the Admin Menu. There doesn't seem to be a way to do this, am I missing something? I know I can control the display order of the Main Menu but I can't figure out how to order the Admin Menu Icons.

Thanks

Doug P



89
phillipd
Re:Dual or tri column output
  • 2004/11/4 15:59

  • phillipd

  • Quite a regular

  • Posts: 219

  • Since: 2004/4/20


Works Perfectly! And it was much simpler than the tutorial. Thank you very much!

Doug P



90
phillipd
Re:Where is the 'next' or 'continue' in smarty?
  • 2004/11/4 14:22

  • phillipd

  • Quite a regular

  • Posts: 219

  • Since: 2004/4/20


Yes exactly, I'm needing to do the equivalent of a "next" or "continue" in a smarty foreach or section. This multi column layout problem is kickng my but... I did find this:

http://smarty.incutio.com/?page=SmartyColumnsTutorial

But I'm having a hard time, being new at this, to relate it to XOOPS and checckboxes.

Thanks

Doug P (A rank beginner, but learning all the time)




TopTop
« 1 ... 6 7 8 (9) 10 11 12 ... 22 »



Login

Donat-O-Meter

Stats
Goal: $15.00
Due Date: Sep 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $15.00
Make donations with PayPal!