HTML forms let you customize Net.Data macro operations and are useful for most applications. This example is similar to the monitor list example above, but lets the application user select which product to view. You can invoke the macro from a link like this:
<a href="http://www.ibm.com/cgi-bin/db2www/equiplst.mac/input"> Show hardware list</a>
Here is the macro the link calls:
%DEFINE DATABASE="MNS97"
%HTML(input)%{
<H1>Hardware Query Form</H1>
<HR>
<FORM METHOD=POST ACTION="cgi-bin/db2www/equiplst.mac/report">
<P>What type of hardware do you want to see?
<MENU>
<LI><INPUT TYPE="RADIO" NAME="hdware" VALUE="MON" checked> Monitors
<LI><INPUT TYPE="RADIO" NAME="hdware" VALUE="PNT"> Pointing devices
<LI><INPUT TYPE="RADIO" NAME="hdware" VALUE="PRT"> Printers
<LI><INPUT TYPE="RADIO" NAME="hdware" VALUE="SCN"> Scanners
</MENU>
<INPUT TYPE="SUBMIT" VALUE="Submit">
</FORM>
%}
%FUNCTION(DTW_SQL) myQuery(){
SELECT MODNO, COST, DESCRIP FROM EQPTABLE
WHERE TYPE='$(hdware)'
%REPORT{
<H3>Here is the list you requested</H3>
%ROW{
<HR>
$(N1): $(V1), $(N2): $(V2)
<P>$(N3): $(V3)
%}
%}
%}
%HTML(report){
@myQuery()
%}
After the application user makes a selection and presses the Submit button, the Web server processes the ACTION parameter of the FORM tag, which invokes Net.Data to call the HTML report block. See Net.Data Reference Guide for details of the variables used in the ROW block.