Skip to content
Hub Nexus

No author yetClaim it

Version 1Updated 1 min read

Support

Motivation

You want a simple search function and a separate advanced search options tab.

Source Code

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ev="http://www.w3.org/2001/xml-events">
<title>Google Search Example</title>
<style type="text/css">
body {font-family: Helvetica, sans-serif; }
</style>
<style>
@namespace xf url("http://www.w3.org/2002/xforms");
/* all the attributes of each tab, except the background color */
#horiz-tab-menu xf|trigger {
border-left: black solid 1px;
border-top: black solid 1px;
border-right: black solid 1px;
border-bottom: 0px;
font-weight: bold;
font-family: Helvetica, sans-serif;
font-size: .9em;
margin-right: 5px;
padding: 3px;
/* the following only works under FireFox */
-moz-border-radius: .5em .5em 0em 0em;
border-radius-topright: .5em;
border-radius-topleft: .5em;
}
/* the attributes of each div inside of a case */
xf|switch xf|case {
position: relative;
width: 400;
border: solid black 1px;
border-top: solid black 0px;
border-right: solid black 1px;
border-bottom: solid black 1px;
padding: 5px;
background-color: silver;
}

</style>
<xf:model>
<xf:instance xmlns="" id="search-params">
<data>
<hl>en</hl>
<q />
</data>
</xf:instance>

<xf:instance xmlns="" id="adv-search-input-params">
<data>
<hl>en</hl>
<q>Xforms</q>
<site>http://en.wikibooks.org/wiki/XForms</site>
</data>
</xf:instance>

<xf:instance xmlns="" id="adv-output-input-params">
<data>
<hl>en</hl>
<q />
</data>
</xf:instance>

<xf:bind nodeset="instance('adv-output-input-params')/q"
calculate="concat(
instance('adv-search-input-params')/q, '+', instance('adv-search-input-params')/site)" />

<xf:bind nodeset="instance('adv-output-input-params')/hl"
calculate="instance('adv-search-input-params')/hl"/>

<xf:submission id="search-google" method="get" action="http://www.google.com/search"
replace="all" ref="instance('search-params')" separator="&" />

<xf:submission id="adv-search-google" method="get" action="http://www.google.com/search"
replace="all" ref="instance('adv-output-input-params')" separator="&" />

<xf:action ev:event="xforms-ready">
<xf:setfocus control="search-field" />
</xf:action>
</xf:model>
<body>
<h1>Google Search Example</h1>
<div id="horiz-tab-menu">
<xf:trigger appearance="minimal" class="tab">
<xf:label>Simple</xf:label>
<xf:toggle case="simple-search" ev:event="DOMActivate" />
</xf:trigger>
<xf:trigger appearance="minimal" class="tab">
<xf:label>Complex</xf:label>
<xf:toggle case="advanced-search" ev:event="DOMActivate" />
</xf:trigger>
</div>
<xf:switch>

<xf:case id="simple-search">
<xf:input ref="instance('search-params')/q" id="search-field">
<xf:label>Search string:</xf:label>
<xf:action ev:event="DOMActivate">
<xf:send submission="search-google" />
</xf:action>
</xf:input>
<xf:submit submission="search-google">
<xf:label>Search</xf:label>
</xf:submit>
</xf:case>

<xf:case id="advanced-search">
<xf:input ref="instance('adv-search-input-params')/q" id="adv-search-field">
<xf:label>Search string:</xf:label>
<xf:action ev:event="DOMActivate">
<xf:send submission="adv-search-google" />
</xf:action>
</xf:input>
<br />
<xf:input ref="instance('adv-search-input-params')/site" id="site-field">
<xf:label>Site URL:</xf:label>
<xf:action ev:event="DOMActivate">
<xf:send submission="adv-search-google" />
</xf:action>
</xf:input>
<br />
<xf:submit submission="adv-search-google">
<xf:label>Search</xf:label>
</xf:submit>
</xf:case>

</xf:switch>
</body>
</html>

Where this page came from

This page was imported from Wikibooks. From “XForms” on Wikibooks, by its contributors, under CC BY-SA 4.0. Changed here: set as a page; navigation and edit links left out; each image under its own licence, credited in its caption.

Nobody has written it yet — it is the source material at a new address, which is why search engines are asked to skip it and why no one earns from it. It is up for grabs: take it on, and it is yours to rewrite and to earn from.

Get each new page of

XForms

Following means one email when a page is added, nothing when a page changes.

Following means one email when a page is added, nothing when a page changes.

Comments

Spinner Logo

Next in XForms

CC BY-SA 4.0
It must run from a webserver. To run this application you MUST enable XForms to submit data to other domains. In FireFox this is done by adding the domains to your trusted list. This can be done by going to the FireFox "Tools" menu, selecting Preferences, selecting the "Content" tab, and adding the
CC BY-SA 4.0
Web services can be called directly from an XForms application using the **submission** element in the model. ## Connecting a web service to an Event To call a web service you first need to "wire it" up to an event. For example this can be a "submit" button at the end of a form. The submit element i
CC BY-SA 4.0
XForms, Search Amazon
CC BY-SA 4.0
- Uncompress the zip file on your local file system - Change any occurrences of **"&"** to **& a m p ;** and remove **& n b s p ;** and **& c o p y ;** in the HTML files to make the files well formed XHTML files so that eXist can index them. The following files in the 3.2 release will need to be mod
CC BY-SA 4.0
This updates the visible image. Note that the output must have a the mediatype set to be **image/*** for the browser to render the link as an image correctly. ## Attribution This example was created by Chris Wallace and the University of Western England.
CC BY-SA 4.0
The way to visualize this is to imagine a set divided into two distinct subsets: selected and un-selected items. As an item moves from the un-selected item set to the selected item set it must first be added to the new set and then deleted from the old set. ## Method This example uses a combination