Open main menu

Wikibooks β

XForms/Highlight Selected Row

< XForms



It is very often useful to highlight the selected row. This is done with a xform-repeat-index pseudo element in the style sheet.


By adding the following to your CSS the selected row will be highlighted in blue:

     .xforms-repeat-index {
        background-color: blue;

Screen ImageEdit

This example highlights the background of the selected row.  

This example was run using the FormFaces system.

Program CodeEdit

<html xmlns=""
      <title>XForms Delete Example</title>
      <!-- I used the formfaces system to test this -->
      <script type="text/javascript" src="formfaces.js"></script>
      <style type="text/css">
     * {
        font-family: Ariel, Helvetica, sans-serif;
     label, legend {
        font-weight: bold;
      .header {
        color: white;
        background-color: gray;
        font-weight: bold;
        padding: 2px;
      .header {
         width: 370px;
       .leftColumn, .rightColumn {
         display: inline;
      .leftColumn {
         margin-left: 10px;
      .rightColumn {
         position: absolute;
         left: 0;
         margin-left: 150px;
      fieldset {
         width: 380px;
      .xforms-repeat-index {
        background-color: blue;

            <PhoneList xmlns="">
                  <Name />
                  <Phone />
               <SelectedRow />
      <xf:group nodeset="/PhoneList">
         <legend>Company Phone List</legend>
         <div class="header">
            <div class="leftColumn">Name</div>
            <div class="rightColumn">Phone</div>
         <xf:repeat id="list" nodeset="Person">
            <xf:input ref="Name" class="leftColumn"><xf:label></xf:label></xf:input>
            <xf:input ref="Phone" class="rightColumn"><xf:label></xf:label></xf:input>
         <legend>Add New Person</legend>
         <xf:input ref="NewPerson/Name">
         <br />
         <xf:input ref="NewPerson/Phone">
            <xf:label>Insert After Selected Row</xf:label>
            <xf:action ev:event="DOMActivate">
               <xf:insert nodeset="Person" at="index('list')" position="after" />
               <xf:setvalue ref="Person[index('list')]/Name" value="/PhoneList/NewPerson/Name" />
               <xf:setvalue ref="Person[index('list')]/Phone" value="/PhoneList/NewPerson/Phone" />
               <xf:setvalue ref="SelectedRow" value="index('list')" />
         <xf:label>Delete Selected Row</xf:label>
         <xf:action ev:event="DOMActivate">
            <xf:delete nodeset="Person" at="index('list')" />
      <xf:output ref="SelectedRow">
         <xf:label>Selected Row= </xf:label>


Note that this only works when you select a row an click your cursor on the input field. The result is that the value of the index for the selected list will change. This can be used by the functions that add or delete a selected row.

Known bugsEdit

This appears to not be functional under the FireFox extension as of 0.6.

Next Page: Table Column Total | Previous Page: Insert and Delete into Table

Home: XForms