Categories > OpenTBS with DOCX >

checkboxes

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Lily
Date: 2012-02-17
Time: 13:59

checkboxes

Hi all,

From yesterday I am using TBS with OpenTBS plugin to generate .docx templates. I find this solution great and unique!
I am little lost now with the checkboxes...My application is at following: online application (PHP) that saves data in Mysql and after submiting the data, there is option to download the .docx.
I have succeed to auto fill in the text fields in the .docx, but I cannot find solution to check the checkboxes if the value is 1, or to let them unchecked if their value is 0.

Thank you in advance for your help
By: Skrol29
Date: 2012-02-18
Time: 01:50

Re: checkboxes

Hi Lily,

There is a double difficulty :

First, check-boxes are not the same inner structure in Word 2007 and Word 2010. But I guess you know the format you are using for your template.

Ans also, you must change two values in the inner structure of the check-box in order to set it checked or unchecked.
The first value is the attribute of the element <w14:checked w14:val="0"/> (using Word 2010)
This is easy because the attribute value is 1 for checked, 0 for unchecked.

Unfortunately, this does not change the display.
So you have also the change the symbole. This can be changed only by changing manually the XML source, and replace:
       <w:sdtContent>
          <w:r>
            <w:rPr>
              <w:rFonts w:ascii="MS Gothic" w:eastAsia="MS Gothic" w:hAnsi="MS Gothic" w:hint="eastAsia"/>
            </w:rPr>
            <w:t>☐</w:t>
          </w:r>
        </w:sdtContent>
with:
       <w:sdtContent>
          <w:r>
            <w:rPr>
              <w:rFonts w:ascii="MS Gothic" w:eastAsia="MS Gothic" w:hAnsi="MS Gothic" w:hint="eastAsia"/>
            </w:rPr>
            <w:t>[onshow.opt1;if [val]=1;then ☒;else ☐]</w:t>
          </w:r>
        </w:sdtContent>

This is not simple.

Finally the best wy is may be to use special symbols instead of real Ms Word check-boxes.
Then you just have to code something like :
[onshow.opt1;if [val]=1;then ☒;else ☐]