Go Back   CodingForums.com > :: Server side development > ASP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-03-2002, 02:06 AM   PM User | #1
Mhtml
Senior Coder

 
Mhtml's Avatar
 
Join Date: Jun 2002
Location: Sydney, Australia
Posts: 3,531
Thanks: 0
Thanked 1 Time in 1 Post
Mhtml is an unknown quantity at this point
image checkbox add value to db.

Ok, I'm trying to figure how It would be possible to firstly change and img from one to another and then send an on value to a db or text file which would check to see if it had been turned on each time the page loads and change the img accordingly.

I hope that I'm making sense, basically I'm trying to make an image checkbox which remembers if it is checked or not.

I've tried to change the image like this but it doesn't seem to work:
Code:
<%
dim Img1
dim Img2
dim CurrentImg

Img1 = Server.MapPath(/off.png)
Img2 = Server.MapPath(/onn.png) 

CurrentImg = Img1
%>
Then in the <img> I used
Code:
<img src="<%=CurrentImg%>" OnMouseDown="<%=CurrentImg = Img2%>">
__________________
Omnis mico antequam dominus Spookster!
Mhtml is offline   Reply With Quote
Old 08-03-2002, 02:19 AM   PM User | #2
Mhtml
Senior Coder

 
Mhtml's Avatar
 
Join Date: Jun 2002
Location: Sydney, Australia
Posts: 3,531
Thanks: 0
Thanked 1 Time in 1 Post
Mhtml is an unknown quantity at this point
I got the image to change using this
Code:
<%
dim ThisUrl
ThisUrl = "http://127.0.0.1/m5/personal/chbx/chbx.asp?ch1=on"
dim img1
dim img2
dim currentimg
img1 = server.MapPath("off.png")
img2 = server.MapPath("onn.png")
currentimg = img1

if Request.QueryString("ch1") = "on" then
currentimg = img2
end if
%>
and the <img>
Code:
<a href="<%=ThisUrl%>"><img src="<%=currentimg%>" border="0"></a>
But is there a way to do it without sending a querystring like that?
__________________
Omnis mico antequam dominus Spookster!
Mhtml is offline   Reply With Quote
Old 08-04-2002, 01:17 AM   PM User | #3
whammy
Senior Coder

 
Join Date: Jun 2002
Location: 41° 8' 52" N -95° 53' 31" W
Posts: 3,660
Thanks: 0
Thanked 0 Times in 0 Posts
whammy is an unknown quantity at this point
One way, you could have a form with a hidden field, and post that - when you click the image, have javascript change the value of that (hidden) field - then you could get the value of the variable with Request.Form("myhiddenfieldname")

__________________
Former ASP Forum Moderator - I'm back!

If you can teach yourself how to learn, you can learn anything. ;)
whammy is offline   Reply With Quote
Old 08-04-2002, 08:08 AM   PM User | #4
Morgoth
Senior Coder

 
Morgoth's Avatar
 
Join Date: Jun 2002
Location: Ontario, Canada Remaining Brain Cells: 6
Posts: 1,402
Thanks: 2
Thanked 1 Time in 1 Post
Morgoth is an unknown quantity at this point
Well, first off, are you trying to make an onmousedown event?

And OnMouseDown="<%=CurrentImg = Img2%>" will not work.

What you said is exactly this:
Code:
<%
Dim StrA, StrB, StrAB

StrA = 1
StrB = 2

StrAB = StrA

Response.Write StrAB
Response.Write StrAB = StrB
%>
The Answer is:
"1False"
"1" from the first Response.Write.
And
"False" from the second Response.Write.

The answer is False for the second Response.Write, because 1 doesn't equal 2.


To get that code to work right, you'll need to add one more line of code.
Code:
<%
Dim StrA, StrB, StrAB

StrA = 1
StrB = 2

StrAB = StrA
Response.Write StrAB
StrAB = StrB
Response.Write StrAB
%>
This code Returns:
12
"1" from the first Response.Write
And
"2" from the second Response.Write


For your first image tag, why not just do this:
Code:
<img src="<%=Img2%>" OnMouseDown="<%=Img2%>">
Morgoth is offline   Reply With Quote
Old 08-04-2002, 09:30 AM   PM User | #5
Mhtml
Senior Coder

 
Mhtml's Avatar
 
Join Date: Jun 2002
Location: Sydney, Australia
Posts: 3,531
Thanks: 0
Thanked 1 Time in 1 Post
Mhtml is an unknown quantity at this point
uh? hmm....Well Morgoth that is clever, but I to dim to figure how I am to relate that to my problem.

Anywho I'm giving up on this. Thanx anyways, maybe I'll try again in the not to distant future.

Mike..
__________________
Omnis mico antequam dominus Spookster!
Mhtml is offline   Reply With Quote
Old 08-05-2002, 07:51 AM   PM User | #6
Morgoth
Senior Coder

 
Morgoth's Avatar
 
Join Date: Jun 2002
Location: Ontario, Canada Remaining Brain Cells: 6
Posts: 1,402
Thanks: 2
Thanked 1 Time in 1 Post
Morgoth is an unknown quantity at this point
Oh... so you wish not to have a querystring, eh?
Why not send it as a form. (Method="post")
Then you can do something like:
String = Request.Form("ch1")

Help now?
Morgoth is offline   Reply With Quote
Old 08-05-2002, 11:27 AM   PM User | #7
Mhtml
Senior Coder

 
Mhtml's Avatar
 
Join Date: Jun 2002
Location: Sydney, Australia
Posts: 3,531
Thanks: 0
Thanked 1 Time in 1 Post
Mhtml is an unknown quantity at this point
Is there a way to change the image without refreshing the page?
I know how to do it in js but I'd like to be able to do it in asp to be different.

Or should I just stick to browser scripting for this sought of thing?
__________________
Omnis mico antequam dominus Spookster!
Mhtml is offline   Reply With Quote
Old 08-05-2002, 11:26 PM   PM User | #8
whammy
Senior Coder

 
Join Date: Jun 2002
Location: 41° 8' 52" N -95° 53' 31" W
Posts: 3,660
Thanks: 0
Thanked 0 Times in 0 Posts
whammy is an unknown quantity at this point
Without refreshing the page, you have to use javascript to do it, since you aren't sending/retrieiving any information to/from the server.
__________________
Former ASP Forum Moderator - I'm back!

If you can teach yourself how to learn, you can learn anything. ;)
whammy is offline   Reply With Quote
Old 08-06-2002, 09:17 AM   PM User | #9
Morgoth
Senior Coder

 
Morgoth's Avatar
 
Join Date: Jun 2002
Location: Ontario, Canada Remaining Brain Cells: 6
Posts: 1,402
Thanks: 2
Thanked 1 Time in 1 Post
Morgoth is an unknown quantity at this point
ASP is server side, therefore it is not run in real time.
Morgoth is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:54 PM.


Advertisement
Log in to turn off these ads.