michaeldallas
|
| Posted: 04/09/2003, 4:51 PM |
|
Okay smart people, here's one the CCS staff hasn't been able to solve:
I created a form with numerous input fields. I want some of the fields (with their corresponding text and table rows) to "appear" and "disappear" depending on the answers to other fields in the form.
For example, a question might be, "Do you smoke?" If the answer is "Yes", then another question is dynamically inserted into the form below the just answered question. "What do you smoke?" A listbox would then be available for the answer ("tobacco, marijuana, crack"). To achieve this funcationality, I need the ability to make sections of the form appear and disappear.
I've read the articles including "Manipulating Template Variables and Blocks".
http://support.codecharge.com/kb_article.asp?s_keyword=...=&article_id=56
As instructed, I inserted a template block into the record table and around the tags and fields which need to appear and disappear. A simplified version of the html template block appears below:
(I've omitted the html formatting such as colors, etc. for simplicity. But the solution must allow for table formatting to appear and disappear with the <tr></tr> and <td></td> tags.)
<!-- BEGIN Own3Years -->
<tr>
<td>
<select name="{f_8_REOTypeA_Name}">
{f_8_REOTypeA_Options}
</select>
</td>
<td>
<input value="{f_9_OtherRaceExplainA}" name="{f_9_OtherRaceExplainA_Name}">
</td>
</tr>
<!-- END Own3Years -->
The php code which "parses" the block is inserted in the
"//Show Page @1-1945BF5E:" code block of the php template:
$Tpl->Parse("Own3Years",true); // <- This is the added line.
$borrowerinfo_t->Show(); // This line is already here
$Tpl->PParse("main", false); // This line is also already here
Unfortunately, while the text and html tags appear as needed, the input fields (text and listbox) do not work correctly. The fields are blank (and not connected to the database). The listbox list is empty as well.
It appears that the "parse" method only works for non-input objects.
It may be possible to use "template variables" but I'm not sure how to make all the html, data connections, and text boxes work together while appearing and disappearing. A genius definitely is needed here.
QUESTION: How do I make these objects (text boxes, listboxes, and html tags) appear and disappear dynamically in the form while functioning as well?
|
|
|
 |
michaeldallas
|
| Posted: 04/09/2003, 6:59 PM |
|
To make the "parse()" work on input fields, another call to the "Show()" procedure needs to be added just before the "Parse()" statement.
$borrowerinfo_t->Show(); // <- This is the new line that needs to be added.
$Tpl->Parse("Own3Years",true); // This line was added per CCS instructions
$borrowerinfo_t->Show(); // This line is generated in CCS template
$Tpl->PParse("main", false); // This line is generated in CCS template
Your welcome.
|
|
|
 |
michaeldallas
|
| Posted: 04/09/2003, 8:28 PM |
|
The only problem with the first solution is that it creates two copies of the form on the page. A better solution is to copy the "Show()" method into a new method called PreParse(). From there simply comment out the $Tpl->parse(); command in PreParse(). The code in the template will then be:
$borrowerinfo_t->PreParse(); // <- This is the new line that needs to be added.
$Tpl->Parse("Own3Years",true); // This line was added per CCS instructions
$borrowerinfo_t->Show(); // This line is generated in CCS template
$Tpl->PParse("main", false); // This line is generated in CCS template
|
|
|
 |
|