TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 08-09-2009, 03:00 PM   #1 (permalink)
The Contributor
 
russellharrower's Avatar
 
Join Date: Jul 2009
Posts: 80
Thanks: 13
russellharrower is on a distinguished road
Help Update Text if div is showing or hiding

Hi i found this code however it is not updating the text correctly on my computer.

javascript Code:
<script type="text/javascript">

function ShowHide(elementId)
{
    var element = document.getElementById(elementId);
    if(element.style.display != "block")
    {
        element.style.display = "block";
    }
    else
    {
        element.style.display = "none";
    }
}
function UpdateText(element)
{
    if(element.innerHTML.indexOf("Show") = -1)
    {
        element.innerHTML = "show<img src='images/YOUR THEME /fastreply.gif'>";
    }
    else
    {
        element.innerHTML = "hide<img src='images/YOUR THEME/fastreply.gif'>";
    }
}
</script>
php Code:
<?php
print '<a href="javascript:void(0);" onclick="ShowHide(\'search'.$row['id'].'\');UpdateText(this);">';
?>

If anyone can help that would be alsome, I thought it was the UpdateText because I have more then one of these on the same page since it prints it 10 times.

But after 5 hours working at it, can't get it to work...

please help if you can

Last edited by russellharrower : 08-09-2009 at 04:26 PM.
russellharrower is offline  
Reply With Quote
Old 08-09-2009, 03:40 PM   #2 (permalink)
Super Moderator
Inquisitive 
 
codefreek's Avatar
 
Join Date: Sep 2007
Location: Near you.
Posts: 791
Thanks: 241
codefreek is on a distinguished road
Default

Please change, to highlight=javascript
and read, Prettifying Pasted Code on TalkPHP

Thankyou
-cf
codefreek is offline  
Reply With Quote
Old 08-09-2009, 07:09 PM   #3 (permalink)
The Addict
 
Join Date: May 2009
Posts: 287
Thanks: 5
adamdecaf is on a distinguished road
Default

  1. Why are you assigning a value in the 2nd if statement?
  2. Why are you not just checking if the image is displayed and if so set it's .style to hidden. (Then vise-versa)
  3. It would help if we had more context (what exactly you're trying).
  4. http://jslint.com
__________________
My Site
adamdecaf is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
mysql update with multi fields sarmenhb Absolute Beginners 1 02-06-2009 10:03 PM
Input-field with captured text falsely empties on click sidisinsane Javascript, AJAX, E4X 5 12-05-2008 12:12 AM
You are subscribed to this thread mysql update with multi fields sarmenhb Advanced PHP Programming 0 11-15-2008 05:00 AM
mysql update with multi fields sarmenhb General 0 11-15-2008 04:19 AM
PDF Creation - Help! Sam Granger General 7 10-31-2007 11:32 AM


All times are GMT. The time now is 06:10 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design