Date:  11/12/2007 02:56:54 PM Msg ID:  003578
From:  FoxWeb Support Thread:  003577
Subject:  Re: Return a value from a table selection.
You will need to use something like this to retrieve the selected company:
var ddlCompanies = document.getElementById("ddlCompanies");
var selectedValue = ddlCompanies.options[ddlCompanies.selectedIndex].value;

I have not tested the above code, so there may be some syntactical mistakes.

Also, you can't call do DisplOfficeList the way you plan to.  JavaScript code runs on the browser, while DisplOfficeList (I assume) is a PRG file that needs to run on the server.  You have three options:

  1. If the number of companies in the first table is small, have the information about all the companies downloaded to the browser at the beginning of the request and access it via JavaScript once the user selects a company.
  2. Split the tables in two pages and create a wizard-like user interface.  After users select an option in the companies table, they press a Continue button, which would submit the form to the server, which would in turn return information about the selected company.
  3. Use Ajax.  This will allow you to make a behind-the-scenes request to the server to retrieve information about the selected company.  For additional information, search this forum and the web for the term "ajax".  Also, take a look at the ZipSearch sample application that comes with FoxWeb 4.
FoxWeb Support Team
support@foxweb.com email
Sent by George Gambill on 11/12/2007 01:15:44 PM:
We are building a table of companies and want to build second table (same web page) based on a selection from the first table.

 

We are hoping to be able to use something like javascript (onchange) to do this but are open to most any suggestions.  Our code goes something like:

<!-- **** Company List ****-->

<TD style="WIDTH: 276px" vAlign=top><SELECT id=ddlCompanies

style="WIDTH: 156px"

 

onchange="javascript:setTimeout(' <% do DisplOfficeList %>', 0)"

 

name=ddlCompanies>

 

<% Do DisplCompanyList %>

 

<!-- DisplCompanyList returns something like this which works well-->

 

<OPTION value=1 selected>Yellow Book

Company</OPTION> <OPTION value=2>Verizon Yellow Pages</OPTION>

<OPTION value=3>SBC Yellow Pages</OPTION> <OPTION value=4>Los

Angeles Times</OPTION> <OPTION value=5>ypOne</OPTION> <OPTION

value=6>Call Yellow</OPTION> <OPTION value=7>Denver DEX</OPTION>

<OPTION value=8>None</OPTION> <OPTION value=9>AT&amp;T</OPTION>

<OPTION value=10>Transwestern</OPTION> <OPTION value=11>Ross

Directories</OPTION> <OPTION value=12>Drain Patrol</OPTION>

<OPTION value=13>Tehachappi</OPTION> <OPTION value=14>Fine

Directories</OPTION> <OPTION value=15>Penny Saver</OPTION></SELECT>

 

</TD>

 

<!--

The question is how to determine which comapny (i.e. value = 1 or 2 or ....15) was selected???

 

Any help / examples will be greatly appreciated!!!

 

TIA

-->