473,396 Members | 1,913 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Image selector via List Box populated from Database?

I am hoping a mixed ASP- Javascript programmer could help me with this
scenario:

I have a list box populated with randomized records (NewID()) from a Broker
(Salesperson) sql server table.

Each time the user selects one of the broker items I need to display a Image
of the broker in the table cell next to it.

I have found a number of online js scripts that use the image selector route
but I am unable to work out to populate the list
item from the database AND at the same time utilize the JS...

Are there any coders who come across a solution like this. Here is an
example of my ASP code populating the List box:

Set oCmd = GetStoredProcedure(oConn,"spr_GetBroker")
set oRS = oCmd.execute()
Response.write ("<TR><TD class=text><strong>Broker:</strong></TD><TD>")
Response.write "<select name='u_BrokerID' size='4'
onChange='generateimage(this.options[this.selectedIndex].value)'>"
'//Response.Write("<TR><TD
class=text><strong>Broker:</strong></TD><TD><SELECT NAME=u_BrokerID>")
If oRS.eof then
Response.Write("<option>No records found for Nation</option>")
else
while not oRS.eof
Response.Write("<OPTION VALUE=""" & oRS.fields(0) & """>" &
oRS.fields(1) & "</OPTION>")
oRS.movenext
wend
End If

Response.Write("</SELECT>")

I now need to load the images (from the imagePath inside my database ie
rs(3)) and then trigger an event to launch a new image
in the next table cell...

Appreciate any advice!!!

- Jason

Jul 19 '05 #1
2 2090
<ja***@catamaranco.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
:I am hoping a mixed ASP- Javascript programmer could help me with this
: scenario:
:
: I have a list box populated with randomized records (NewID()) from a
Broker
: (Salesperson) sql server table.
:
: Each time the user selects one of the broker items I need to display a
Image
: of the broker in the table cell next to it.
:
: I have found a number of online js scripts that use the image selector
route
: but I am unable to work out to populate the list
: item from the database AND at the same time utilize the JS...
:
: Are there any coders who come across a solution like this. Here is an
: example of my ASP code populating the List box:
:
: Set oCmd = GetStoredProcedure(oConn,"spr_GetBroker")
: set oRS = oCmd.execute()
: Response.write ("<TR><TD class=text><strong>Broker:</strong></TD><TD>")
: Response.write "<select name='u_BrokerID' size='4'
: onChange='generateimage(this.options[this.selectedIndex].value)'>"
: '//Response.Write("<TR><TD
: class=text><strong>Broker:</strong></TD><TD><SELECT NAME=u_BrokerID>")
: If oRS.eof then
: Response.Write("<option>No records found for Nation</option>")
: else
: while not oRS.eof
: Response.Write("<OPTION VALUE=""" & oRS.fields(0) & """>" &
: oRS.fields(1) & "</OPTION>")
: oRS.movenext
: wend
: End If
:
: Response.Write("</SELECT>")
:
: I now need to load the images (from the imagePath inside my database ie
: rs(3)) and then trigger an event to launch a new image
: in the next table cell...
:
: Appreciate any advice!!!

Maybe this will help you get started...untested

sub prt(str)
response.write(str & vbCrLf)
end sub

Set oCmd = GetStoredProcedure(oConn,"spr_GetBroker")
set oRS = oCmd.execute()

prt("<html>")
ptr("<head><title></title>")
prt("<script type=""text/javascript"">")
prt("function generateimage(x) {")
prt(" document.getElementById('brokerimage').src = ""/images/" + x +
".jpg"";")
prt(" }")
prt("</script>")
prt("</head>")
prt("<body>")
prt("<table>")
prt("<tr colspan=2><td class=text><b>Broker:</b></td><tr>")
prt("<tr><td>
prt("<select name=""u_BrokerID"" size=""4""
onChange=""generateimage(this.options[this.selectedIndex].value)"">")
If oRS.eof then
prt("<div>No records found for Nation</div>")
else
do while not oRS.eof
prt("<option value=""" & oRS.fields(0).value & """>" &
oRS.fields(1).value & "</option>")
oRS.movenext
loop
End If
prt("</select></td>")
prt("<td><img id="brokerimage" name="brokerimage" src="""" /></td>")
prt("</table>")
prt("</body>")
prt("</html>")

set oRS = nothing
set oCmd = nothing
--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
Jul 19 '05 #2
Thanks Roland....I am amost got it to work but ran into an object errror...I
then switched direction and go this direction to work(below)...hope it helps
someone.

But now, I have a new dilemma. I have populated my <option value> with the
absolute url....

<option value="/catamaranco/images/brokers/christine_2.jpg">Christine
Buttigieg (sales)</option>

....which means my form processing page can no longer the expect the
"BrokerID" for insert into customer table.

I realise I could concantenate the id like this in the option: "option
value=35_="/catamaranco/images/brokers/christine_2.jpg"

But, then I have to use messy string manipulation on the next page or some
kind of function.

Is there a more elegant way to handle this which will not create problems
for me later on....

Many thanks for you post which got me on the right track.

- Jason

!-- #include virtual="/join/utility.asp" -->
<%
Dim oCmd, oReturn, oConn
set oConn = GetConnection()
Set oCmd = GetStoredProcedure(oConn,"sp_adduser1")
Set oCmd = GetStoredProcedure(oConn,"spr_GetBroker")
set oRS = oCmd.execute()
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled Document</title>
<script language="javascript">
<!--

/*Combo Box Image Selector:
By JavaScript Kit (www.javascriptkit.com)
Over 200+ free JavaScript here!
*/

function showimage()

{
if (!document.images)
return
document.images.pictures.src=
document.mygallery.picture.options[document.mygallery.picture.selectedIndex]
..value

}
//-->
</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="100%"><form name="mygallery"><p>
<select name="picture" size="1" onChange="showimage()">
<%
If oRS.eof then
prt("<div>No records found for Nation</div>")
else
do while not oRS.eof
Response.write ("<option value=""" & oRS.fields(3).value & """>" &
oRS.fields(1).value & "</option>")

oRS.movenext
loop
End If
%>
</form>
</td>
</tr>
<tr>
<td width="100%"><p align="center"><img
src="/catamaranco/images/brokers/michaelharris_2.jpg" name="pictures"
width="99"
height="100"></td>
</tr>
</table>
</body>
</html>

"Roland Hall" <nobody@nowhere> wrote in message
news:eg**************@tk2msftngp13.phx.gbl...
<ja***@catamaranco.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
:I am hoping a mixed ASP- Javascript programmer could help me with this
: scenario:
:
: I have a list box populated with randomized records (NewID()) from a
Broker
: (Salesperson) sql server table.
:
: Each time the user selects one of the broker items I need to display a
Image
: of the broker in the table cell next to it.
:
: I have found a number of online js scripts that use the image selector
route
: but I am unable to work out to populate the list
: item from the database AND at the same time utilize the JS...
:
: Are there any coders who come across a solution like this. Here is an
: example of my ASP code populating the List box:
:
: Set oCmd = GetStoredProcedure(oConn,"spr_GetBroker")
: set oRS = oCmd.execute()
: Response.write ("<TR><TD class=text><strong>Broker:</strong></TD><TD>") : Response.write "<select name='u_BrokerID' size='4'
: onChange='generateimage(this.options[this.selectedIndex].value)'>"
: '//Response.Write("<TR><TD
: class=text><strong>Broker:</strong></TD><TD><SELECT NAME=u_BrokerID>")
: If oRS.eof then
: Response.Write("<option>No records found for Nation</option>")
: else
: while not oRS.eof
: Response.Write("<OPTION VALUE=""" & oRS.fields(0) & """>" &
: oRS.fields(1) & "</OPTION>")
: oRS.movenext
: wend
: End If
:
: Response.Write("</SELECT>")
:
: I now need to load the images (from the imagePath inside my database ie
: rs(3)) and then trigger an event to launch a new image
: in the next table cell...
:
: Appreciate any advice!!!

Maybe this will help you get started...untested

sub prt(str)
response.write(str & vbCrLf)
end sub

Set oCmd = GetStoredProcedure(oConn,"spr_GetBroker")
set oRS = oCmd.execute()

prt("<html>")
ptr("<head><title></title>")
prt("<script type=""text/javascript"">")
prt("function generateimage(x) {")
prt(" document.getElementById('brokerimage').src = ""/images/" + x +
".jpg"";")
prt(" }")
prt("</script>")
prt("</head>")
prt("<body>")
prt("<table>")
prt("<tr colspan=2><td class=text><b>Broker:</b></td><tr>")
prt("<tr><td>
prt("<select name=""u_BrokerID"" size=""4""
onChange=""generateimage(this.options[this.selectedIndex].value)"">")
If oRS.eof then
prt("<div>No records found for Nation</div>")
else
do while not oRS.eof
prt("<option value=""" & oRS.fields(0).value & """>" &
oRS.fields(1).value & "</option>")
oRS.movenext
loop
End If
prt("</select></td>")
prt("<td><img id="brokerimage" name="brokerimage" src="""" /></td>")
prt("</table>")
prt("</body>")
prt("</html>")

set oRS = nothing
set oCmd = nothing
--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp MSDN Library - http://msdn.microsoft.com/library/default.asp

Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: MediaDesign | last post by:
so there's the problem: my text links have background images and when I put links around images on my page, they too get the background image treatment which I do not...I have tried several...
1
by: John | last post by:
Hi, I have a jsp that generates rows (depending on how many records are available in the database) with data and an image and each row alternates its color. In each <tr> I have 2 <td>: one for...
7
by: Megan | last post by:
Hi everybody- I inherited a database that somehow uses a bound combo box as a record selector. Let me give you some background. The form is based on data from 2 tables. The first table, Person,...
8
by: Galina | last post by:
Hello I have 6 dependent list boxes on my ASP page:  Faculty;  Lecturer;  Course;  Course occurrence;  Group;  Week commencing date. When faculty is selected, lists of lecturers and...
5
by: jung_h_park | last post by:
From: jung_h_park@yahoo.com Newsgroups: microsoft.public.dotnet.framework.aspnet Subject: Dropdown List not retaining its SelectedValue Date: Mon, 26 Jun 2006 21:02:57 -0700 Hello, My...
4
by: John Smith | last post by:
I have a continuous form. there is a command button with the following code for the OnClick event: DoCmd.OpenForm "frmPlants", , , "PlantsID =" & Me!PlantsID I click the button and frmPlants...
2
by: Poppa Pimp | last post by:
ImageResizer.php Image Resizer PLEASE HELP The URL of the page this is on in my site is http://poppa-pimps-wallpapers.com//ImageResizer.php You can click on browse and get image,but...
18
by: Nik Coughlin | last post by:
I am halfway through writing a tutorial on image slicing for fluid CSS layouts, I would love some feedback on what I've done up until this point: http://nrkn.com/index.html I am still writing...
1
by: neovantage | last post by:
Hey all, I am using a PHP script which creates headings at run time in a sense at page execution. I am stuck a with a very little problem which i am sure i will have the solution from experts. ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.