form_example.lzx

<!-- Example of using the form tag -->
<canvas bgcolor="0xeaeaea" width="640">

    <!-- An url that reads submitted form data -->
    <!-- and echoes it back in a response -->
    <dataset name="echoer" src="http:echo.jsp"/>

    <text id="tt" x="40" y="15" width="500" multiline="true" resize="false" height="40">
        Here are two examples forms.  Hitting the <b>submit</b>
        button will display the data that is received by the server.
    </text>

    <!-- Tabs view with a few forms in it -->
    <tabs id="tb" x="40" y="$once{tt.y + tt.height}"> 
      <tabpane text="Example 1">
        <form id="ex1">
            <submit name="submitter" dataset="${echoer}"/>

            <statictext>What is your definition of fun?</statictext>
            <radiogroup x="30" name="definition">
                <radiobutton value="1">Playing video games</radiobutton>
                <radiobutton value="2">Chatting with friends</radiobutton>
                <radiobutton value="3">Eating french fries</radiobutton>
            </radiogroup>

            <statictext>Where do you live?</statictext>
            <list name="home" x="30" shownitems="4"> 
                <textlistitem selected="true">city</textlistitem>
                <textlistitem>town</textlistitem>
                <textlistitem>island</textlistitem>
                <textlistitem>village</textlistitem>
                <textlistitem>cubby hole</textlistitem>
            </list>

            <checkbox name="email">Please send me email that is fun.</checkbox>

            <button isdefault="true" onclick="parent.submitter.submit()">Submit</button>
        </form>
      </tabpane>

      <tabpane text="Example 2">
        <form height="${ex1.height}" layout="axis: y; spacing: 15">
            <submit name="submitter" dataset="${echoer}"/>

            <view layout="axis: x; spacing: 5">
                <text y="2">First name:</text>
                <edittext width="120" name="firstname">Wilma</edittext>
            </view>
            <view layout="axis: x; spacing: 5">
                <text y="2">Last name:</text>
                <edittext width="120" name="lastname">Flintstone</edittext>
            </view>

            <statictext>Things that aren't fun (select a few):</statictext>
            <list width="175" name="pain" x="20" multiselect="true" shownitems="5"> 
                <textlistitem selected="true">Kidney stones</textlistitem>
                <textlistitem selected="true">Blisters</textlistitem>
                <textlistitem>Brain freeze</textlistitem>
                <textlistitem>Parking in San Francisco</textlistitem>
                <textlistitem>Null pointer exceptions</textlistitem>
                <textlistitem/>
            </list>

            <button isdefault="true" onclick="parent.submitter.submit()">Submit</button>
        </form>
     </tabpane>
   </tabs>
    
   <!-- Simple display of data echoed back by the server -->
   <tabs x="${tb.x+tb.width+30}" y="${tb.y}" width="220" height="${tb.height}" datapath="echoer:/response"> 
       <tabpane width="${parent.width}">Results
           <view layout="axis: y; spacing: 2">
               <view datapath="formcomponent" layout="axis:y">
                   <text width="100" datapath="@name" fontstyle="bold"/>
                   <text x="5" resize="true" multiline="true" width="${this.parent.parent.parent.width - this.x}" datapath="text()"/>
               </view>
           </view>
       </tabpane>
   </tabs>
</canvas>
<!-- * X_LZ_COPYRIGHT_BEGIN ***************************************************
* Copyright 2001-2008 Laszlo Systems, Inc.  All Rights Reserved.              *
* Use is subject to license terms.                                            *
* X_LZ_COPYRIGHT_END ****************************************************** -->
<!-- @LZX_VERSION@                                                         -->

Cross References

Named Instances