View Full Version : sending a form
candide.kemmler
05-17-2003, 11:56 AM
Sorry for the possibly stupid question...
I'd like to send a form... How do I do ?
I've hesitated to put that in the wishlist ! All the examples concentrate on client-side execution, but hey, you cannot completely forget about the client-server paradigm, can you ?
BTW: very professional website ! thumbs up.
antun
05-17-2003, 12:47 PM
You submit to a script (e.g. JSP, PHP, ASP, CGI etc.)on any server. At the most basic level, say you have a single text field:
<canvas>
<dataset name="myData"
src="http://www.laszlosystems.com/cgi-pub/weather.cgi"
type="http" autorequest="false" />
<inputtext name="myTextField">Enter zip here
</inputtext>
</canvas>
... and you have a script on some server (we'll use our weather script here) that takes an HTTP GET variable (called 'zip') as an argument. I declared a dataset above - that's where the XML data that our CGI script returns will go.
var z = myTextField.getText();
canvas.datasets.myData.setQueryString({zip: z});
canvas.datasets.myData.doRequest();
That's a really quick example. You could put a lot more stuff in the querystring above. Alternatively, if you had a big, complex form, you might bind the text fields to a blank dataset, so every time that the user changed the data in the form, it would be reflected in the dataset. Then you could send the whole dataset as XML to the server.
-Antun
bgardella
11-04-2003, 02:52 PM
I get from this explanation that a given jsp or cgi has to be able to understand xml?
I would expect that this:
<dataset name="loginData"
src="http://localhost:8888/do/logon"
type="http" autorequest="false" />
<button x="75" label="Login">
<method event="onclick">
var d = canvas.datasets.loginData;
var p = new LzParam();
var user = parent.username.getText();
var pass = parent.password.getText();
p.addValue("username", user, true);
p.addValue("password", pass, true);
d.setQueryString( p );
d.doRequest();
</method>
</button>
would produce this:
http://localhost:888/do/logon?username=foo&password=bar
Am I crazy?
--ben
antun
11-04-2003, 03:08 PM
I get from this explanation that a given jsp or cgi has to be able to understand xml?
No - maybe there's been a misunderstanding. A script on the server that you access using a <dataset> (and all the other APIs, such as setQueryString() and doRequest, etc.), needs to return XML, but it can take regular CGI GET or POST variables.
The example you gave looks right, however there's a bug right now that will prevent the code you posted from working. You have to call the toString() method of LzParam before passing it into setQueryString():
d.setQueryString( p.toString() );
-Antun
jimineep
05-12-2006, 04:18 AM
I have a form and I cant work out for the life of me how to post it. I want to post the chosen text items to the decond dataset (db2xml_pathway.pl) which will then return xml results which i display in antother piece of code
<dataset name="org_data" type="http" request="true" src="http://terra.no-ip.org/~jimp/db2xml_orglist.pl" />
<dataset name="pathway_data" type="http" request="true" src="http://terra.no-ip.org/~jimp/db2xml_pathway.pl" />
<form id="sel_org">
<text>Select your organisms</text><text> (use ctrl to select more than one) </text>
<list id="org_select_list" multiselect="true" width="90%" shownitems="3">
<textlistitem
datapath ="org_data:/orgList/organism/orgName"
text="$path{'text()'}"
value="$path{'text()'}"/>
</list>
<view>
<simplelayout axis="y" spacing="4"/>
<button height="20">Clear Selection
<method event="onclick">
var val = org_select_list.clearSelection();
</method>
</button>
<button height="20">Check Selection
<method event="onclick">
var val = org_select_list.getValue();
org_select_listval.setText(val);
</method>
</button>
<button height="30" isdefault="true"> Submit
<method event="onclick">
orgSelectPathway.setAttribute('visible', true);
</method>
</button>
</view>
</form>
Cheers for any help, it is tricky following the examples here, label and autorequest are not longer valid
Cheers, Jim
pathogen
05-12-2006, 06:17 AM
Hi Jim, in your form tag declare this:
<submit name="pathwayDataSubmitter" data="${pathway_data}"/>
Then, in the method for your submit button, add:
pathwayDataSubmitter.submit();
jimineep
05-12-2006, 07:48 AM
Thanks for the speedy reply!
I'd tried that and it was unfortunately it still doesnt seem to work. I think the problem might be that the search results (the orgSelectPathway window) that uses the values of the db2xml_pathway.pl file is produced when the application starts, ie before it has been passed the parameters, not dynamically.
Basically i need to pass the orgSelectPathway window the results of db2xml_pathway.pl?ORGNAME=(value for ORGNAME) in order for it to produce the XML which the orgSelectPathway window displays:
<canvas debug="true">
<dataset name="org_data" type="http" request="true" src="http://terra.no-ip.org/~jimp/db2xml_orglist.pl" />
<dataset name="pathway_data" type="http" request="true" src="http://terra.no-ip.org/~jimp/db2xml_pathway.pl" />
<form id="sel_org" name="sel_org">
<submit name="pathway_dataSubmit" id="pathway_dataSubmit" data="${ pathway_data }" />
<text>Select your organisms</text><text> (use ctrl to select more than one) </text>
<list id="org_select_list" multiselect="true" width="90%" shownitems="3">
<textlistitem
datapath ="org_data:/orgList/organism/orgName"
text="$path{'text()'}"
value="$path{'text()'}" name="ORGNAME"/>
</list>
<view>
<simplelayout axis="y" spacing="4"/>
<button height="20">Clear Selection
<method event="onclick">
var val = org_select_list.clearSelection();
</method>
</button>
<button height="20">Check Selection
<method event="onclick">
var val = org_select_list.getValue();
org_select_listval.setText(val);
</method>
</button>
<button height="30" isdefault="true"> Submit
<method event="onclick">
orgSelectPathway.setAttribute('visible', true);
pathway_dataSubmit.submit();
</method>
</button>
</view>
</form>
<window name="orgSelectPathway" id="orgSelectPathway" title="choose your pathway" visible="false">
<list id="orgPathway" width="95%" shownitems="10">
<textlistitem
datapath ="pathway_data:/pathwayList/pathway/fullName"
text="$path{'text()'}"
value="$path{'text()'}"/>
</list>
</window>
</canvas>
hmmm... i hope im not missing anything too basic!
pathogen
05-12-2006, 08:21 AM
Ah, ok. So you need to pass in the ORGNAME as a param. Try this in the submit button method before pathway_dataSubmit.submit():
var selectedOrgName = org_select_list.getValue();
Debug.write(selectedOrgName);
pathway_data.setQueryParam('ORGNAME', selectedOrgName);
Be advised that getValue() can return an array if multiple items are selected as I see you allow in the list. Depending on what kind of parsing of request params you are doing in your .pl, you may need to do something more direct:
var selectedOrgNames = org_select_list.getValue();
//figure out if you have an array and if so, build the query string in a for loop
queryString = '?ORGNAME=' + selectedOrgNames[0];
for(var i = 1; i < selectedOrgNames.length; i++){
queryString += '&ORGNAME=' + org_select_list.getValue();
}
pathway_data.setAttribute('querystring', queryString);
vBulletin® v3.8.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.