Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

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

Posts: 7
Trades: 0
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 11:14 AM.. Reason: Changed _ to = in bottom link
firemail is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 05-10-2008, 12:59 PM Re: Coverting Javascript to PHP call
Inet411's Avatar
Skilled Talker

Posts: 88
Name: programmer
Location: internet
Trades: 0
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.
__________________

Please login or register to view this content. Registration is FREE

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

Posts: 7
Trades: 0
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 Search this Thread
Search this Thread:

Advanced Search

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
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.38350 seconds with 12 queries