Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Variable won't update with onclick

Status
Not open for further replies.

ekwstats

MIS
Feb 2, 2004
70
US
I am trying to change the picture description with an onclick event. I have it working where it updates a text field with the pic description but the text field has size limitation so I just wanted to have text(strPhotoDescrip).

Everything seems to work...the alert shows the right Photo Description, the image updates, but nothing will ever show up after the Testing. And nothing shows up in the view source so it's like it's not recognizing strPhotoDescrip.

<IMG name="imgMain" width="250" border="1" src="db/listimages/<%= strPhoto %>"><br>
Testing <%= strPhotoDescrip %><br>

strPhoto2 = "<a href=""/db/listimages/" & oRS.Fields(14).Value & """ onclick=""document.images.imgMain.src=this.href;strPhotoDescrip ='" & oRS.Fields(28).Value & "';alert(strPhotoDescrip);return false;""><IMG border=""0"" width=""114"" border=""0"" src=""db/listimages/" & oRS.Fields(14).Value & """></a>
Thanks!!
 
What do you mean 'the picture description'?

*cLFlaVA
----------------------------
A pirate walks into a bar with a huge ship's steering wheel down his pants.
The bartender asks, "Are you aware that you have a steering wheel down your pants?"
The pirate replies, "Arrrrr! It's driving me nuts!
 
strPhotoDescrip=Picture Description = oRS.Fields(28).Value
 
Example
The 2nd and 3rd image are set with the code above. The others use this...which works.

strPhoto4 = "<a href=""/db/listimages/" & oRS.Fields(16).Value & """ onclick=""document.images.imgMain.src=this.href;document.PhotoDescrip.txtPhotoDescrip.value ='" & oRS.Fields(30).Value & " ';return false;""><IMG border=""0"" width=""114"" border=""0"" src=""db/listimages/" & oRS.Fields(16).Value & """></a>
 
Worked on this forever last night with still no luck. Anyone know why strPhotoDescrip is not getting a value in Testing <%= strPhotoDescrip %><br>?
Thanks
 
do a view source and give us as to how the <a> tag looks...

Known is handfull, Unknown is worldfull
 
This is the source for the link that the user needs to click.

<a href="/db/listimages/1381_back.jpg" onclick="document.images.imgMain.src=this.href;strPhotoDescrip ='Covered rear patio';alert(strPhotoDescrip);return false;">

The View source of the Testing area shows nothing to the right of it.

There is also the link I posted above so you can see the behavior.


Thanks
 
what is <% and %> doing in javascript?

??

*cLFlaVA
----------------------------
A pirate walks into a bar with a huge ship's steering wheel down his pants.
The bartender asks, "Are you aware that you have a steering wheel down your pants?"
The pirate replies, "Arrrrr! It's driving me nuts!
 
I realize this is incorrect...but I don't know anything about ASP or JavaScript and I don't know what to put in there. I have tried JS functions...document.write etc, with no luck. The <% was just another attempt at guessing what might be wrong.
What should I have after the Test?
Thanks
 
Ahh, ok! I think that's why everyone was so confused.

Try this:

Change this:
Testing <%= strPhotoDescrip %><br>

To this:
<div id="pic_description">
This is the default picture description.
</div>

And then, have your anchor as this:
<a href="/db/listimages/1381_back.jpg" onclick="document.images.imgMain.src=this.href;document.getElementByID('pic_description').innerHTML = 'Covered rear patio';">

Let me know if this helps.


*cLFlaVA
----------------------------
A pirate walks into a bar with a huge ship's steering wheel down his pants.
The bartender asks, "Are you aware that you have a steering wheel down your pants?"
The pirate replies, "Arrrrr! It's driving me nuts!
 
Sorry-

getElementByID should be getElementById

CASE SENSITIVITY!!!

*cLFlaVA
----------------------------
A pirate walks into a bar with a huge ship's steering wheel down his pants.
The bartender asks, "Are you aware that you have a steering wheel down your pants?"
The pirate replies, "Arrrrr! It's driving me nuts!
 
Yahoo. That worked. Thank you!!! I would have never figured that out.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top