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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with this code. 1

Status
Not open for further replies.

EdRev

Programmer
Aug 29, 2000
510
US
I have JScript that runs on the client side.

function toggleHideShow()
{
if (document.all.advancedOptions.style.display == "none")
{
document.all.advanceOption.style.display="block";
var optimg="\\...\...\showimg.gif";
}
else
{
document.all.advanceOption.style.display="none";
var optimg="\\...\...\hideimg.gif";
}
}

on the body, I have this:

<input type=image src=<%=optimg%> style=&quot;display:block&quot; LANGUAGE=javascript onclick=&quot;toggleHideShow()&quot;>

Can anybody tell me what I'm doing wrong, it doesn't seem to work.





 
I don't see the name or id in the input tag your trying to reference...

-Tarwn --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
Can't...think...of...anything...funny...to.........say............
need.....coffee....................
 
Thanks,

I forgot to put it, but still didn't work. Should be

<input type=image src=<%=optimg%> style=&quot;display:block&quot; id=&quot;AdvancedOptionButton&quot; LANGUAGE=javascript onclick=&quot;toggleHideShow()&quot;>
 
since optimage is a server-side variable you can't set it from client-side. Instead try:
document.all.advanceOption.src=&quot;\\...\...\showimg.gif&quot;;

That way you will be changing thwe client-side value of the image source.

-Tarwn --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
Can't...think...of...anything...funny...to.........say............
need.....coffee....................
 
Thanks again,

How can I reference this on the <input> tag?
 
function toggleHideShow()
{
if (document.all.advancedOptions.style.display == &quot;none&quot;)
{
document.all.advanceOption.style.display=&quot;block&quot;;
document.all.advancedOptions.src=&quot;\\...\...\showimg.gif&quot;;
}
else
{
document.all.advanceOption.style.display=&quot;none&quot;;
document.all.advancedOptions.src=&quot;\\...\...\hideimg.gif&quot;;
}
}

That should work. I'm not sure if the links to your images will resolve correctly though. You may want to check those paths.

-tarwn
--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
With enough resources, time, and coffee, anything is possible.
 
Thanks again.

But how will I reference this on my <input> tag?
i.e. <input type=image src=?>
 
Your input tag should be ok. Your writing the initial value to it from the ASP variable which is fine. The only thing you need to do is make sure you have the id set like you do a few posts up.

-Tarwn --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
With enough resources, time, and coffee, anything is possible.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top