472,992 Members | 3,578 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,992 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 2075
<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: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
3
SueHopson
by: SueHopson | last post by:
Hi All, I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...

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.