Current location: Hot Scripts Forums » Programming Languages » ASP » Combo box image change with names from database


Combo box image change with names from database

Reply
  #1 (permalink)  
Old 07-06-06, 06:00 PM
Frogger Frogger is offline
Wannabe Coder
 
Join Date: Jul 2006
Posts: 149
Thanks: 5
Thanked 0 Times in 0 Posts
Combo box image change with names from database

Hi,

I have being trying to work out this problem for hours hense why I am asking for some help now please. I am trying to use data from a database where I can change an image when I make a selection from a combo box. The combo box can read the values from the database fine. I just cant work out how to make the image change when I make the corresponding selection.
See below for info in access database

filename plantname
cordyline.jpg CORDYLINE AUSTRALIS
CYCAD.jpg CYCAS REVOLUTA
BANGALOW_PALM.jpg ARCHONTOPHOENIX CUNNINGHAMIANA

Below is the script. I am trying to make the blank.gif image change to the filename when I select the plantname from the corresponding selection.
IE when I select CORDYLINE AUSTRALIS I want the blank.gif to chnage to the cordyline.jpg image. I guess the onchnage function has to be used just not sure where or even if I have set this up correctly. Can anyone please help me on this.

Frogger


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>plants</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">


</head>

<body>
<table width="770" height="576" border="1" cellpadding="0" cellspacing="0">
<tr align="center" valign="middle">
<td width="50%"><img src="images/blank.gif" name="blank" width="150" height="150" id="blank">
</td>
<td width="50%"><img src="images/blank.gif" name="blank2" width="150" height="150" border="0" id="blank2"></td>
</tr>
<tr align="center" valign="middle">


<td width="50%">

<form name="choose">

<select name="list" >
<%

Response.Buffer = true

dim cnn,rst
set cnn = Server.CreateObject("ADODB.Connection")
set rst = Server.CreateObject("ADODB.RecordSet")
cnn.Open "driver={Microsoft Access Driver (*.mdb)};;DBQ=c:/www/plants.mdb;"
sqltext = "SELECT * FROM plants"


Set RS = cnn.Execute(sqltext)
WHILE NOT RS.EOF

%>
<option value="<%=RS("filename")%>"><%=RS("plantname")%></option>
<%

RS.MoveNext
WEND
RS.Close
cnn.Close
%>
</select>
</form>


</td>

<td width="50%">&nbsp;</td>
</tr>
</table>
</body>
</html>
Reply With Quote
  #2 (permalink)  
Old 07-06-06, 09:21 PM
koncept
Guest
 
Posts: n/a
add a javascript onchange event to it to change the image file name. i can try and dig up a script that does that if you need me to
Reply With Quote
  #3 (permalink)  
Old 07-08-06, 07:58 PM
Frogger Frogger is offline
Wannabe Coder
 
Join Date: Jul 2006
Posts: 149
Thanks: 5
Thanked 0 Times in 0 Posts
Reading records in Alphabetical order

Thanks very much for that.

I found some script that helped.

<select id="list1" onchange="document.getElementById('blank1').src=th is.options[this.selectedIndex].value">

I just have one more question.

For some reason my ASP script reads the access database records in the order that they are put in. The access database is saved in alphabetical order. How do I get my combo boxes to display the records in alphabetical order as to the access database ?

Regards
Frogger
Reply With Quote
  #4 (permalink)  
Old 07-08-06, 08:26 PM
koncept
Guest
 
Posts: n/a
in your sql statement it probaly reads "select * from my table.." add at the end order by column (column is the one you want it sorted on, to add multipes add a comma between then, the order they are in is the order they will be sorted by then
Reply With Quote
  #5 (permalink)  
Old 07-09-06, 04:54 AM
Frogger Frogger is offline
Wannabe Coder
 
Join Date: Jul 2006
Posts: 149
Thanks: 5
Thanked 0 Times in 0 Posts
thanks for your help with that... all sorted... regards frogger
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Image Change on every refresh jaishalg PHP 9 03-26-11 01:10 PM
Combo Box Question iamtat Visual Basic 3 10-18-05 01:49 PM
Combo Box Search creepycridler PHP 1 09-14-05 08:55 AM
Loading an image into database with customerID pecobrown PHP 2 02-27-04 01:11 PM
How to change text dynamically with image? rabbit51 Script Requests 0 02-07-04 12:14 PM


All times are GMT -5. The time now is 03:48 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.