Link to home
Start Free TrialLog in
Avatar of Axter
AxterFlag for United States of America

asked on

populate a combo box (SELECT) via DATASRC

http://www.axter.com/tmp/index.htm
http://www.axter.com/tmp/atm_screen_links.txt

I have the above files, in which I'm trying to populate a combo box with data that is in the text file.
As shown in the above index.htm file, I can easily do this in a table by using DATASRC and DATAFLD.
However, I can't figure out what is the required syntax to do this in a SELECT field.
I've tried the following, but it doesn't work, and no data gets inserted.

<form>
<select NAME="filter2" datasrc="#screen_links" DATAFLD="GroupNo" DATAFORMATAS="html">
 <option><DIV DATAFLD="GroupNo"></DIV>
</select>
</form>

I've also looked for javascript code that would pull the data, and populate it via option member, but I haven't found anything that works.

If you look at the above index.htm link, you'll notice I have two comboboxes.  One I filled in the data manually, and the other I'm trying to get filled in programmatically.
So if I get the second one working, it should look like the first one.
Avatar of Michel Plungjan
Michel Plungjan
Flag of Denmark image

E.g.

<HEAD>
<STYLE>
.bound{behavior: url("DataSelect.htc")}
H1{font: bold 18pt verdana; color: navy;}
P{font: 10pt verdana;}
</STYLE>
</HEAD>
<BODY>
<SELECT NAME="oTest"
   CLASS="bound"
   DATASRC="#oData"
   VALUE="4a"
   DATAFLDTEXT="column2"
   DATAFLDVALUE="column1"
</SELECT>
<!-- Data source object must be present -->
<OBJECT ID="oData" CLASSID="clsid:333C7BC4-460F-11D0-BC04-0080C7055A83">
   <PARAM NAME="DataURL" VALUE="dataselect.txt">
   <PARAM NAME="FieldDelim" VALUE=",">
</OBJECT>
</BODY>
Avatar of Axter

ASKER

I'm not familiar with the syntax used in that link.
Is this XML code?
Will it work with IE 5.x?

Can you post an example that would work with posted files?


Avatar of Axter

ASKER

I just tried the following, but the combo box failed to get populated.

<SELECT NAME="oTest"
  DATASRC="#screen_links"
  VALUE="4a"
  DATAFLDTEXT="GroupNo"
  DATAFLDVALUE="GroupNo"
</SELECT>
The examples from MSDN, Michel and your last, all they miss a closing > character.

Here a tested example:

<HEAD>
<STYLE>
.bound{behavior: url("DataSelect.htc")}
H1{font: bold 18pt verdana; color: navy;}
P{font: 10pt verdana;}
</STYLE>
</HEAD>
<BODY>
<SELECT NAME="screen_select"
  CLASS="bound"
  DATASRC="#screen_links"
  VALUE="4a"
  dataFldText="Title"
  dataFldValue="Link"
>
</SELECT>
</p>
<OBJECT ID="screen_links" CLASSID="clsid:333C7BC4-460F-11D0-BC04-0080C7055A83">
      <PARAM NAME="DataURL" VALUE="atm_screen_links.txt">
      <PARAM NAME="UseHeader" VALUE="True">
      <PARAM NAME="FieldDelim" VALUE="&#09;">
</OBJECT>
</BODY>



Thanks for the missing > Zvonko
Avatar of Axter

ASKER

I still have problems using this without the dataselect.htc and the <style> code.

How can I accomplish this without this file?
Avatar of Axter

ASKER

I tried removing the CLASS property, and it still fails to work if I don't have a style and associated file.
Here's the new code.

<HTML><HEAD><TITLE>Main Index for normal</TITLE>
<SCRIPT LANGUAGE="JavaScript">
function filterInCommon(form) {
      var filterExpr1 = form.filter1.options[form.filter1.selectedIndex].value
      var filterExpr =  "GroupNo=" + filterExpr1
      screen_links.Filter = filterExpr
      screen_links.Reset()
}
</SCRIPT>
</HEAD>
<BODY BGCOLOR="white" TOPMARGIN="0">

<FORM>
<SELECT NAME="screen_select" class="bound" ALIGN="CENTER"
 DATASRC="#screen_links"
 VALUE=""
 dataFldText="GroupNo"
 dataFldValue="GroupNo"
>
</SELECT>
</FORM>



<TABLE DATASRC="#screen_links" BORDER=1 ALIGN="center">
<THEAD STYLE="background-color:yellow; text-align:center">
<TR><TD>GroupNo</TD>
      <TD>ScreenNo</TD>
      <TD>Title</TD>
</TR>
</THEAD>
<TR>
      <TD><DIV DATAFLD="GroupNo" ></DIV></TD>
      <TD><DIV DATAFLD="ScreenNo"></DIV></TD>
      <TD><P ALIGN="CENTER"><A target="_top" HREF=<DIV DATAFLD="Link"></DIV><DIV DATAFLD="Title"></DIV></A></P></TD>
</TR>
</TABLE>

<OBJECT ID="screen_links" CLASSID="clsid:333C7BC4-460F-11D0-BC04-0080C7055A83">
      <PARAM NAME="DataURL" VALUE="atm_screen_links.txt">
      <PARAM NAME="UseHeader" VALUE="True">
      <PARAM NAME="FieldDelim" VALUE="&#09;">
</OBJECT>


</BODY></HTML>
Avatar of Axter

ASKER

Correction:

<HTML><HEAD><TITLE>Main Index for normal</TITLE>
<SCRIPT LANGUAGE="JavaScript">
function filterInCommon(form) {
      var filterExpr1 = form.filter1.options[form.filter1.selectedIndex].value
      var filterExpr =  "GroupNo=" + filterExpr1
      screen_links.Filter = filterExpr
      screen_links.Reset()
}
</SCRIPT>
</HEAD><BODY BGCOLOR="white" TOPMARGIN="0">


<FORM>
<SELECT NAME="screen_select" ALIGN="CENTER"
 DATASRC="#screen_links"
 VALUE=""
 dataFldText="GroupNo"
 dataFldValue="GroupNo"
>
</SELECT>
</FORM>



<TABLE DATASRC="#screen_links" BORDER=1 ALIGN="center">
<THEAD STYLE="background-color:yellow; text-align:center">
<TR><TD>GroupNo</TD>
      <TD>ScreenNo</TD>
      <TD>Title</TD>
</TR>
</THEAD>
<TR>
      <TD><DIV DATAFLD="GroupNo" ></DIV></TD>
      <TD><DIV DATAFLD="ScreenNo"></DIV></TD>
      <TD><P ALIGN="CENTER"><A target="_top" HREF=<DIV DATAFLD="Link"></DIV><DIV DATAFLD="Title"></DIV></A></P></TD>
</TR>
</TABLE>

<OBJECT ID="screen_links" CLASSID="clsid:333C7BC4-460F-11D0-BC04-0080C7055A83">
      <PARAM NAME="DataURL" VALUE="atm_screen_links.txt">
      <PARAM NAME="UseHeader" VALUE="True">
      <PARAM NAME="FieldDelim" VALUE="&#09;">
</OBJECT>
</BODY></HTML>
Avatar of Axter

ASKER

Also, is there a way to pull just the unique GroupNo fields?
I'm still playing with this..
ASKER CERTIFIED SOLUTION
Avatar of Zvonko
Zvonko
Flag of North Macedonia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Axter

ASKER

Zvonko,
Outstanding!!!

Thank you very much.
Avatar of Axter

ASKER

For any one else who is interested, here's the complete working version of the code which dynamically fills in the combobox and the table, and aslo includes the splash screen code.
I removed the *.htc reference, so other then the *.txt data file, this code is stand alone.

<HTML><HEAD><TITLE>Main Index for normal</TITLE>
<style>
   H1        { font: bold 18pt verdana; color: navy }
                   
   P         { font: 10pt verdana;}
   
   A:link    { color:#003399; text-decoration:none; }
   A:visited { color:#6699CC; text-decoration:none; }
   A:hover   { text-decoration:underline; }

   #scr_splash { font: bold 18pt verdana; color:red; text-align:center; }
   #scr_lnks { display:none; }
</style>

<SCRIPT LANGUAGE="JavaScript">
function fillOpt(selName) {
 opt = document.forms[0][selName].options;
 opt.length=0;
 oGid="";
 tBody = document.getElementsByTagName('table')[0];
 for(i=1;i<tBody.rows.length;i++){
   gID = tBody.rows[i].cells[0].firstChild.innerHTML;
   if(gID!=oGid){
     opt[opt.length] = new Option(gID, gID)
   }
   oGid=gID;
 }
    var filterExpr1 = document.all.screen_select.options[0].value
    var filterExpr =  "GroupNo=" + filterExpr1
    screen_links.Filter = filterExpr
    screen_links.Reset()
    document.all.scr_splash.style.display = "none"
    document.all.scr_lnks.style.display = "block"
}

function filterInCommon() {
    var filterExpr1 = document.all.screen_select.options[document.all.screen_select.selectedIndex].value
    var filterExpr =  "GroupNo=" + filterExpr1
    screen_links.Filter = filterExpr
    screen_links.Reset()
}


</SCRIPT>
</HEAD><BODY BGCOLOR="white" TOPMARGIN="0" onLoad="fillOpt('screen_select')">
<DIV ID="scr_splash">Data is being loaded, please wait...</DIV>
<DIV ID="scr_lnks">



<FORM>
<SELECT NAME="screen_select" ALIGN="CENTER" onChange="filterInCommon()"
DATASRC="#screen_links"
VALUE=""
dataFldText="GroupNo"
dataFldValue="GroupNo"
onChange="filterInCommon()"
>
</SELECT>
</FORM>



<TABLE DATASRC="#screen_links" BORDER=1 ALIGN="center">
<THEAD STYLE="background-color:yellow; text-align:center">
<TR><TD>GroupNo</TD>
    <TD>ScreenNo</TD>
    <TD>Title</TD>
</TR>
</THEAD>
<TR>
    <TD><DIV DATAFLD="GroupNo" ></DIV></TD>
    <TD><DIV DATAFLD="ScreenNo"></DIV></TD>
    <TD><P ALIGN="CENTER"><A target="_top" HREF=<DIV DATAFLD="Link"></DIV><DIV DATAFLD="Title"></DIV></A></P></TD>
</TR>
</TABLE>

<OBJECT ID="screen_links" CLASSID="clsid:333C7BC4-460F-11D0-BC04-0080C7055A83">
    <PARAM NAME="DataURL" VALUE="atm_screen_links.txt">
    <PARAM NAME="UseHeader" VALUE="True">
    <PARAM NAME="FieldDelim" VALUE="&#09;">
</OBJECT>
</BODY></HTML>
Could you please post an example text file too?

Thanks
The text file is this link (found in the question):
http://www.axter.com/tmp/atm_screen_links.txt

Here some first lines:
GroupNo      ScreenNo      Link      Title
0001      0001      atm_index_grp0001_scrn0001.htm      This is the screen used when MAC DP-ATM is closed.
0001      0006      atm_index_grp0001_scrn0006.htm      Please stand-by while your transaction is processing.
0001      0008      atm_index_grp0001_scrn0008.htm      THis screen reminds the customer to take the receipt.
0001      0009      atm_index_grp0001_scrn0009.htm      This screen reminds the customer not to forget his card.
0001      0010      atm_index_grp0001_scrn0010.htm      Card retained.
0001      0044      atm_index_grp0001_scrn0044.htm      Contains the palette for the MAC Check screens -- c:\user\pict\group2\closed.pcx
0001      0502      atm_index_grp0001_scrn0502.htm      FRAGMENT: ACTION SELECTED IS NOT AVAILABLE.
0001      0599      atm_index_grp0001_scrn0599.htm      TRANSACTION CAN NOT BE COMPLETED.
0001      0600      atm_index_grp0001_scrn0600.htm      SUPERVISOR MAIN MENU.
0001      0601      atm_index_grp0001_scrn0601.htm      SUPERVISOR -- REPLENISHMENT
0001      0602      atm_index_grp0001_scrn0602.htm      SUPERVISOR -- SETTLEMENT MENU
0001      0603      atm_index_grp0001_scrn0603.htm      SUPERVISOR -- UPDATE CUSTOMER GRAPHICS
0001      0604      atm_index_grp0001_scrn0604.htm      SUPV CONFIGURATION -- MENU
0001      0605      atm_index_grp0001_scrn0605.htm      SUPERVISOR -- REPLENISHMENT-DEPOSIT COUNTERS.
0001      0606      atm_index_grp0001_scrn0606.htm      SUPERVISOR -- REPLENISHMENT-DISPLAY DEPOSIT COUNTERS.
0001      0607      atm_index_grp0001_scrn0607.htm      SUPERVISOR -- REPLENISHMENT-CLEAR DEPOSIT COUNTERS.
0001      0608      atm_index_grp0001_scrn0608.htm      SUPV-REPLENISHMENT -- INIT BILLS MENU FOR SINGLE MODE
0001      0609      atm_index_grp0001_scrn0609.htm      SUPV-REPLENISHMENT -- TEST PRINTERS MENU

Thanks for the points and for the feedback.
Zvonko
Avatar of Axter

ASKER

Both the file and the link can be downloaded from the following links:
http://www.axter.com/tmp/index.htm
http://www.axter.com/tmp/atm_screen_links.txt

FYI:
This text file has tab characters that are used as a deliminator character for the fields.
This can be changed to a different character, but then you have to modify the following line in the HTML file.
 <PARAM NAME="FieldDelim" VALUE="&#09;">

This is important to know, because if you just copy the previously posted text into a file, it will more then likely fail if the tab characters haven't been carried over.


>>Thanks for the points and for the feedback.

Thank you for the solution.  
I've looked through a bunch of PAQ's and a lot of newsgroups messages, and I've seen the question asked many times, but no one seem to have a working method posted.
Now you have one :)
I am getting
document.all.screen_select.options[0].value
is null or not an object
Michel, do you know that: Doctor, when I press here then it hurts! Doctor: Then do not press there :)
not funny. Just trying to see it work and it does not work for me

Michel
So you do say you need help? LOL! :)
Glad to see you got it all working.. not bad for a C++ monkey :)

I came across these which you might could use, dunno. They just filter the data loaded on startup...

Added to <object>:
 
     <PARAM NAME="FilterColumn" VALUE="GroupNo">
     <PARAM NAME="FilterCriterion" VALUE="<=">
     <PARAM NAME="FilterValue" VALUE="0003">

Where..

     [FilterColumn] [FilterCriterion] [FilterValue]

Doing this would load all the "0003" columns and any value less than that, which would include "0001". Only thing is you can't load data outside the initial filter, so this would only be good if you had data you never wanted to show, or for a static page or a for a page with a limited subset of the original data.

Not sure if you can use that but thought I'd share regardless :)
Avatar of Axter

ASKER

>>I am getting
>>document.all.screen_select.options[0].value
>>is null or not an object

Do you get this when you try pulling up the link I posted?
If so, what browser are you using?
Avatar of Axter

ASKER

>>Not sure if you can use that but thought I'd share regardless :)

I wouldn't be able to use it for this paticular requirement, but it is good info to know for possible future use.
Thanks
IE6.02 on XP using the code found at the link - the link itself does not seem to do anything
Avatar of Axter

ASKER

>> the link itself does not seem to do anything
What exactly do you mean when you say it doesn't do anything?

Do you get a blank page?
Now it works...

Thanks