Re: Specify default on drop-down based on DRW?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Jim Buyens (news_at_interlacken.com)
Date: 02/17/04


Date: 16 Feb 2004 19:42:45 -0800


"Augie Dawg" <NO_SPAMaugiedawg@earthlink.net> wrote in message news:<nl8Yb.6150$tL3.631@newsread1.news.pas.earthlink.net>...
> Jim:
>
> I did as you suggested, placing the (appropriately modified) script after
> the SUBMIT button definition but before the </form> tag using the INSERT
> HTML Web component, and nothing happened. I also placed the script after
> the </form> tag, and that didn't work either, I'm still seeing the first
> entry in the database column as opposed to the current value. Am I
> misunderstanding your directions, or did I not clearly state my problem? In
> case it's the latter, I'm thinking I need to be able to somehow modify the
> drop-down list properties to include an entry that would show the currently
> selected record first.

I'm posting the page I used for testing below. It uses the "Sample"
Northwind database. Extraneous line endings may keep it from working
on your system but you should get the idea.

You can't modify the drop-down list properties because the DRW
manufactures the drop-down list's HTML on the fly. That's why I had to
write JavaScript to look at the values in the completed list and set
the selectedIndex property to the one that contains the previous
value.

Are you sure you changed the name CategoryID to thE name of your
drop-down list in all four places?

<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=windows-1252">
<title>DRW Drop-Down List with Memory</title>
</head>
<body>
<form>
  <nobr><!--webbot bot="DatabaseRegionStart"
  s-columnnames="CategoryID,CategoryName,Description"
  s-columntypes="3,202,203" s-dataconnection="Sample"
  b-tableformat="FALSE" b-menuformat="TRUE"
  s-menuchoice="CategoryName" s-menuvalue="CategoryID"
  b-tableborder="TRUE" b-tableexpand="TRUE"
  b-tableheader="TRUE" b-listlabels="TRUE"
  b-listseparator="TRUE" i-listformat="0"
  b-makeform="FALSE" s-recordsource="Categories"
  s-displaycolumns="CategoryID,CategoryName" s-criteria
  s-order s-sql="SELECT * FROM Categories"
  b-procedure="FALSE" clientside suggestedext="asp"
  s-defaultfields s-norecordsfound="No records returned."
  i-maxrecords="256" i-groupsize="0" botid="0"
  u-dblib="../_fpclass/fpdblib.inc"
  u-dbrgn1="../_fpclass/fpdbrgn1.inc"
  u-dbrgn2="../_fpclass/fpdbrgn2.inc"
  preview=" &lt;span style=&quot;color: rgb(0,0,0); background-color:
rgb(255,255,0)&quot;&gt;Database&lt;/span&gt; "
  startspan --><!--#include file="../_fpclass/fpdblib.inc"-->
<% if 0 then %>
<SCRIPT Language="JavaScript">
document.write("<div style='background: yellow; color: black;'>The
Database Results component on this page is unable to display database
content. The page must have a filename ending in '.asp', and the web
must be hosted on a server that supports Active Server Pages.</div>");
</SCRIPT>
<% end if %>
<%
fp_sQry="SELECT * FROM Categories"
fp_sDefault=""
fp_sNoRecords="No records returned."
fp_sDataConn="Sample"
fp_iMaxRecords=256
fp_iCommandType=1
fp_iPageSize=0
fp_fTableFormat=False
fp_fMenuFormat=True
fp_sMenuChoice="CategoryName"
fp_sMenuValue="CategoryID"
fp_sColTypes="&CategoryID=3&CategoryName=202&Description=203&"
fp_iDisplayCols=2
fp_fCustomQuery=False
BOTID=0
fp_iRegion=BOTID
%>
<!--webbot bot="DatabaseRegionStart" endspan
  i-checksum="47909" --><select name="CategoryID" size="1">
  <!--webbot bot="AspInclude" clientside
  u-incfile="../_fpclass/fpdbrgn1.inc" startspan --><!--#include
file="../_fpclass/fpdbrgn1.inc"-->
  <!--webbot bot="AspInclude" endspan i-checksum="56958" -->
  <option value="<%=FP_FieldHTML(fp_rs,"CategoryID")%>"><%=FP_FieldHTML(fp_rs,"CategoryName")%>
  </option>
  <!--webbot bot="AspInclude" clientside
  u-incfile="../_fpclass/fpdbrgn2.inc" startspan --><!--#include
file="../_fpclass/fpdbrgn2.inc"-->
  <!--webbot bot="AspInclude" endspan i-checksum="57022" -->
  </select><!--webbot bot="DatabaseRegionEnd"
  b-tableformat="FALSE" b-menuformat="TRUE"
  u-dbrgn2="../_fpclass/fpdbrgn2.inc" i-groupsize="0"
  clientside
  preview=" &lt;span style=&quot;color: rgb(0,0,0); background-color:
rgb(255,255,0)&quot;&gt;Results&lt;/span&gt; "
  startspan --><!--webbot bot="DatabaseRegionEnd"
  endspan --></nobr>&nbsp;&nbsp;&nbsp;&nbsp;
  <input type="submit" name="btnSub" value="Submit">
  <script>
for (i = 0;
     i < document.forms[0].CategoryID.options.length - 1;
     i++) {
  if (document.forms[0].CategoryID.options[i].value
      == "<%=request("CategoryID")%>"){
    document.forms[0].CategoryID.selectedIndex = i;
    break;
  }
}
</script>
</form>
</body>
</html>

Jim Buyens
Microsoft FrontPage MVP
http://www.interlacken.com
Author of:
*----------------------------------------------------
|\---------------------------------------------------
|| Microsoft Office FrontPage 2003 Inside Out
||---------------------------------------------------
|| Web Database Development Step by Step .NET Edition
|| Microsoft FrontPage Version 2002 Inside Out
|| Faster Smarter Beginning Programming
|| (All from Microsoft Press)
|/---------------------------------------------------
*----------------------------------------------------



Relevant Pages

  • Re: Using HTML_Table
    ... Currently I am using the script below, ... database to display the table info in an HTML table. ... echo mysqli_connect_errno; ...
    (comp.lang.php)
  • Re: need client side form converts get to a post
    ... Given that much of data to be submitted, you should use a POST request and a ... <!DOCTYPE html> ...  The content model of HTML SCRIPT ... thanks for your post, the output is a get from a desktop database, i ...
    (comp.lang.javascript)
  • Using HTML_Table
    ... I have been trying to use HTML_Table from PEAR to write a PHP script ... database to display the table info in an HTML table. ...
    (comp.lang.php)
  • Re: PHP web design patterns
    ... the html pages being the view and the processing script ... and some guidelines from "Database Design for Mere Mortals," which I ... pointers on other suitable patterns, that will cover both web & database? ...
    (alt.php)
  • Cant make this page work
    ... I can't make this script work properly. ... The script at the bottom of the html page ... Does someone have a perl ... sub output_trace_headers { ...
    (comp.lang.javascript)