Reply
Coverting Javascript to PHP call
Old 05-10-2008, 10:12 AM Coverting Javascript to PHP call
Novice Talker

Posts: 7
HI,
I'm relatively new to PHP, PERL veteran.

I've been having trouble getting a javascript to work in firefox. Would it be possible to convert it into a php sub.

The rest of the site is in PHP but for some reason I never thought to try writing the javascript into my php includes as PHP script.

Here is the javascript
HTML Code:
<script language="JavaScript">
 function toggleVisibility(me){
  if (me.style.visibility=="visible"){
   me.style.visibility="hidden";
   }
  else {
   me.style.visibility="visible";
   document.forms['f'].elements['_user'].focus();
   }
  }
</script>
This is a simplified version of the markup
HTML Code:
<a onclick="toggleVisibility(mydiv)">Click to Show / Hide</a>
<div id="mydiv" style="visibility:hidden;">Shows this DIV</div>
You can see it in development @ http://www.firemail.ca/phpsearch/?lang=en
it's the "login" link @ top right.

Thanks in advance

Last edited by firemail : 05-10-2008 at 10:14 AM. Reason: Changed _ to = in bottom link
firemail is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
     
Old 05-10-2008, 11:59 AM Re: Coverting Javascript to PHP call
Inet411's Avatar
Skilled Talker

Posts: 81
Name: programmer
Location: internet
Try this in your header:

HTML Code:
<script type="text/javascript" language="JavaScript"><!--
function HideContent(d) {
if(d.length < 1) { return; }
document.getElementById(d).style.display = "none";
}
function ShowContent(d) {
if(d.length < 1) { return; }
document.getElementById(d).style.display = "block";
}
function ReverseContentDisplay(d) {
if(d.length < 1) { return; }
if(document.getElementById(d).style.display == "none") { document.getElementById(d).style.display = "block"; }
else { document.getElementById(d).style.display = "none"; }
}
//--></script>

Your html:
HTML Code:
<a onclick="ReverseContentDisplay(mydiv)">Click to Show / Hide</a>
<div id="mydiv" style="visibility:hidden;">Shows this DIV</div>

untested.
Inet411 is offline
Reply With Quote
View Public Profile Visit Inet411's homepage!
 
Old 05-10-2008, 01:27 PM Re: Coverting Javascript to PHP call
Novice Talker

Posts: 7
No, doesnèt work, returns errors in IE nothing in firefox.
I guess I forgot to mention Iève tried about a dozen variations and it still doesnèt work. Tried getelementbyname, tried ('mydiv') in single quotes, every variation fails in both browsers. only the one I posted work; in IE only.
I think i need to clean up the PÙHP architecture before I continue, this error may be because the script isnèt in the right place in the site. Lotès of includes!!
Thanks though,

Alex
firemail is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Coverting Javascript to PHP call
 

Thread Tools

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 Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.11526 seconds with 13 queries