Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - filling combobox
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

filling combobox

 Post Reply Post Reply
Author
t.vdplaats View Drop Down
Newbie
Newbie


Joined: 02 April 2005
Location: Netherlands
Status: Offline
Points: 6
Post Options Post Options   Thanks (0) Thanks(0)   Quote t.vdplaats Quote  Post ReplyReply Direct Link To This Post Topic: filling combobox
    Posted: 05 April 2005 at 7:00am
Can someone help me to modify the default.asp that the list will be shown in a combobox (news_id and news_title) instead of a list???
 
here's the content of the default.asp (standard webwizNews default.asp):
 
<% Option Explicit %>
<!--#include file="common.asp" -->
<%
Dim rsNews   'Database recordset holding the news items
Dim intRecordPositionPageNum 'Holds the number of the page the user is on
Dim intRecordLoopCounter 'Loop counter to loop through each record in the recordset
Dim intTotalNumNewsEntries 'Holds the number of News Items there are in the database
Dim intTotalNumNewsPages 'Holds the number of pages the News Items cover
Dim intLinkPageNum  'Holds the number of the other pages of news itmes to link to

'If this is the first time the page is displayed then set the record position is set to page 1
If Request.QueryString("PagePosition") = "" Then
 intRecordPositionPageNum = 1
'Else the page has been displayed before so the news item record postion is set to the Record Position number
Else
 intRecordPositionPageNum = CInt(Request.QueryString("PagePosition"))
End If 
%>
<html>
<head>
<title></title>
<link rel="stylesheet" href="../stylesheet.CSS" type="text/css">
</head>
<body class="backvlak">
</body>
 

 <%
'Create recorset object
Set rsNews = Server.CreateObject("ADODB.Recordset")
 
'Initalise the strSQL variable with an SQL statement to query the database by selecting all tables ordered by the decending date
strSQL = "SELECT tblNews.* FROM tblNews ORDER BY News_Date DESC;"
'Set the cursor type property of the record set to dynamic so we can naviagate through the record set
rsNews.CursorType = 3
 
'Query the database
rsNews.Open strSQL, adoCon
'Set the number of records to display on each page by the constant set in the common.asp file
rsNews.PageSize = intRecordsPerPage
 
'Get the record poistion to display from
If NOT rsNews.EOF Then rsNews.AbsolutePage = intRecordPositionPageNum

'If there are no rcords in the database display an error message
If rsNews.EOF Then
 'Tell the user there are no records to show
 Response.Write "<span class=""text""><br>There are no News Items to read"
 Response.Write "<br>Please check back later</span>"
 Response.End
 

'Display the News Items
Else 
 
 'Count the number of News Items database
 intTotalNumNewsEntries = rsNews.RecordCount 
 
 'Count the number of pages of News Items there are in the database calculated by the PageSize attribute set above
 intTotalNumNewsPages = rsNews.PageCount

 'Display the HTML number number the total number of pages and total number of records
 %>
 
<br>
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center" class="normal">
 <tr>
    <td align="center" class="text"></td>
 </tr>
</table>
<br>
<%
 'For....Next Loop to display the News Items in the database
 For intRecordLoopCounter = 1 to intRecordsPerPage
  'If there are no records then exit for loop
  If rsNews.EOF Then Exit For 
 %>
<table width="95%" border="0" align="center" cellpadding="1" cellspacing="0">
 <tr>
    <td class="link"><strong><a href="news_item.asp?NewsID=<% = rsNews("News_ID") %>" target="_self">
      <% = rsNews("News_title") %>
      </a></strong> <span class="normal"></span> </td>
 </tr>
</table>
<br><%
  'Move to the next record in the recordset
  rsNews.MoveNext
 Next
End If
'Display an HTML table with links to the other News Items
%>
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
 <tr>
  <td> <table width="100%" border="0" cellpadding="0" cellspacing="0">
    <tr>
          <td width="50%" align="center" class="normal">
            <%
'If there are more pages to display then add a title to the other pages
If intRecordPositionPageNum > 1 or NOT rsNews.EOF Then
 Response.Write vbCrLf & "  Page:&nbsp;"
End If
'If the News Items page number is higher than page 1 then display a back link     
If intRecordPositionPageNum > 1 Then
 Response.Write vbCrLf & "   <a href=""default.asp?PagePosition=" &  intRecordPositionPageNum - 1  & """ target=""_self"">&lt;&lt;&nbsp;Prev</a>&nbsp;"          
End If      

'If there are more pages to display then display links to all the pages
If intRecordPositionPageNum > 1 or NOT rsNews.EOF Then
 
 'Display a link for each page in the News Items      
 For intLinkPageNum = 1 to intTotalNumNewsPages  
  
  'If the page to be linked to is the page displayed then don't make it a hyper-link
  If intLinkPageNum = intRecordPositionPageNum Then
   Response.Write vbCrLf & "       " & intLinkPageNum
  Else
  
   Response.Write vbCrLf & "       <a href=""default.asp?PagePosition=" &  intLinkPageNum  & """ target=""_self"">" & intLinkPageNum & "</a>&nbsp;"   
  End If
 Next
End If

'If it is Not the End of the News Items entries then display a next link for the next News Items page       
If NOT rsNews.EOF then    
 Response.Write vbCrLf & "  <a href=""default.asp?PagePosition=" &  intRecordPositionPageNum + 1  & """ target=""_self"">Next&nbsp;&gt;&gt;</a>"     
End If       

'Finsh HTML the table
%>
          </td>
    </tr>
   </table>
   </td>
 </tr>
</table>
<%
'Reset server objects
rsNews.Close
Set rsNews = Nothing
Set strCon = Nothing
Set adoCon = Nothing
%>
<br>
<div align="center"> </div>
Back to Top
snooper View Drop Down
Mod Builder Group
Mod Builder Group
Avatar

Joined: 23 April 2002
Location: Israel
Status: Offline
Points: 333
Post Options Post Options   Thanks (0) Thanks(0)   Quote snooper Quote  Post ReplyReply Direct Link To This Post Posted: 05 April 2005 at 6:33pm
%>
<select name="NameHERE">
<% For intRecordLoopCounter = 1 to intRecordsPerPage
  'If there are no records then exit for loop
  If rsNews.EOF Then Exit For 
 %>
 <option value="<% = rsNews("News_ID") %>"><% = rsNews("News_title") %></option>
<%
  'Move to the next record in the recordset
  rsNews.MoveNext
 Next
%>
</select>
<%
Back to Top
t.vdplaats View Drop Down
Newbie
Newbie


Joined: 02 April 2005
Location: Netherlands
Status: Offline
Points: 6
Post Options Post Options   Thanks (0) Thanks(0)   Quote t.vdplaats Quote  Post ReplyReply Direct Link To This Post Posted: 06 April 2005 at 2:53am
Thanx snooper.. that did the job!
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.