Connecting Tech Pros Worldwide Forums | Help | Site Map

Is this possible?

Leoa
Guest
 
Posts: n/a
#1: Aug 29 '07
Can you use javascript to activate a php function like so:
<?php
$tab="Tab.gif";
function myfunction($txt)
{
$tab = $txt;
echo($tab);
}

?>
<div class="backg" onMouseOver="<? php myfunction("Tab3.gif"); ?>"
STYLE="background-image: url(<?=$img_dir?>/images/<?php echo($tab);?
Quote:
)"
I'm trying to dynamically change the tab button when the when the user
mouse over the tab.

this site has the nav in a module.

any suggestions please....


Jake
Guest
 
Posts: n/a
#2: Aug 29 '07

re: Is this possible?


Yes, it's possible, but not in the way that you are thinking. You
should try looking into AJAX.

Leoa wrote:
Quote:
Can you use javascript to activate a php function like so:
<?php
$tab="Tab.gif";
function myfunction($txt)
{
$tab = $txt;
echo($tab);
}
>
?>
<div class="backg" onMouseOver="<? php myfunction("Tab3.gif"); ?>"
STYLE="background-image: url(<?=$img_dir?>/images/<?php echo($tab);?
Quote:
>)"
>
I'm trying to dynamically change the tab button when the when the user
mouse over the tab.
>
this site has the nav in a module.
>
any suggestions please....
>
Steve
Guest
 
Posts: n/a
#3: Aug 29 '07

re: Is this possible?



"Leoa" <leondria.barbee@gmail.comwrote in message
news:1188422263.801132.124720@r34g2000hsd.googlegr oups.com...
| Can you use javascript to activate a php function like so:
| <?php
| $tab="Tab.gif";
| function myfunction($txt)
| {
| $tab = $txt;
| echo($tab);
| }
|
| ?>
| <div class="backg" onMouseOver="<? php myfunction("Tab3.gif"); ?>"
| STYLE="background-image: url(<?=$img_dir?>/images/<?php echo($tab);?
| )"
|
| I'm trying to dynamically change the tab button when the when the user
| mouse over the tab.

php executes on the server. javascript (etc.) executes in the browser on the
client's pc. this is strickly a javascript endeavor. however, here's how i'd
think about it...


<div mOverSrc="<?= $img_dir ?>/images/Tab3.gif"
mResetSrc="<?= $img_dir ?>/images/<?= $tab ?>"
onmouseover="this.style.backgroundImage = url(this.mOverSrc);"
onmouseout="this.style.backgroundImage = url(this.mResetSrc);"
Quote:
>
something like that allows you to set the images in php yet toggle them on
the client using javascript. i haven't checked the above, so there may be
syntax type problems. it's more or less, just to help you think about it in
another way.

cheers.


Steve
Guest
 
Posts: n/a
#4: Aug 29 '07

re: Is this possible?



"Steve" <no.one@example.comwrote in message
news:V_lBi.82$tb5.58@newsfe12.lga...
|
| "Leoa" <leondria.barbee@gmail.comwrote in message
| news:1188422263.801132.124720@r34g2000hsd.googlegr oups.com...
|| Can you use javascript to activate a php function like so:
|| <?php
|| $tab="Tab.gif";
|| function myfunction($txt)
|| {
|| $tab = $txt;
|| echo($tab);
|| }
||
|| ?>
|| <div class="backg" onMouseOver="<? php myfunction("Tab3.gif"); ?>"
|| STYLE="background-image: url(<?=$img_dir?>/images/<?php echo($tab);?
|| )"
||
|| I'm trying to dynamically change the tab button when the when the user
|| mouse over the tab.
|
| php executes on the server. javascript (etc.) executes in the browser on
the
| client's pc. this is strickly a javascript endeavor. however, here's how
i'd
| think about it...
|
|
| <div mOverSrc="<?= $img_dir ?>/images/Tab3.gif"
| mResetSrc="<?= $img_dir ?>/images/<?= $tab ?>"
| onmouseover="this.style.backgroundImage = url(this.mOverSrc);"
| onmouseout="this.style.backgroundImage = url(this.mResetSrc);"
| >

of course you'd want to add in:

style="background-image:url(<?= $img_dir ?>/images/<?= $tab ?>);"

so that the default image is displayed in the div when the page loads.


Morlaath@gmail.com
Guest
 
Posts: n/a
#5: Aug 30 '07

re: Is this possible?


On Aug 29, 5:04 pm, "Steve" <no....@example.comwrote:
Quote:
"Steve" <no....@example.comwrote in message
>
news:V_lBi.82$tb5.58@newsfe12.lga...
|| "Leoa" <leondria.bar...@gmail.comwrote in message
>
|news:1188422263.801132.124720@r34g2000hsd.googleg roups.com...
|| Can you use javascript to activate a php function like so:
|| <?php
|| $tab="Tab.gif";
|| function myfunction($txt)
|| {
|| $tab = $txt;
|| echo($tab);
|| }
||
|| ?>
|| <div class="backg" onMouseOver="<? php myfunction("Tab3.gif"); ?>"
|| STYLE="background-image: url(<?=$img_dir?>/images/<?php echo($tab);?
|| )"
||
|| I'm trying to dynamically change the tab button when the when the user
|| mouse over the tab.
|
| php executes on the server. javascript (etc.) executes in the browser on
the
| client's pc. this is strickly a javascript endeavor. however, here's how
i'd
| think about it...
|
|
| <div mOverSrc="<?= $img_dir ?>/images/Tab3.gif"
| mResetSrc="<?= $img_dir ?>/images/<?= $tab ?>"
| onmouseover="this.style.backgroundImage = url(this.mOverSrc);"
| onmouseout="this.style.backgroundImage = url(this.mResetSrc);"
| >
>
of course you'd want to add in:
>
style="background-image:url(<?= $img_dir ?>/images/<?= $tab ?>);"
>
so that the default image is displayed in the div when the page loads.
I really don't see why people keep pointing out that php is server
side and javascript is client-side, is if that makes it impossible to
implement. JSP is server-side as well, and you can embed JSP scriplets
and what not into javascript just fine. Just because code is server
side doesn't mean it has to execute on the first pass (which seems to
be what php does) .... i.e if I wanted to do something like this in
JSP it would work just like you would expect.

<script>
function foo() {
<%
String bar = "foobar";

if(bar != null) { %>
//do some javascript stuff
<% } %>
alert(<%=bar%>);
etc.....
}
</script>

<input type="button" value="penguins" onclick="foo();"/>

Not that I'm saying you should switch to Java webapps especially since
webhosts charge too much to run JBoss, Tomcat, etc and Java Struts or
JSF is much harder to learn and implement. But .....

Jerry Stuckle
Guest
 
Posts: n/a
#6: Aug 30 '07

re: Is this possible?


Morlaath@gmail.com wrote:
Quote:
On Aug 29, 5:04 pm, "Steve" <no....@example.comwrote:
Quote:
>"Steve" <no....@example.comwrote in message
>>
>news:V_lBi.82$tb5.58@newsfe12.lga...
>|| "Leoa" <leondria.bar...@gmail.comwrote in message
>>
>|news:1188422263.801132.124720@r34g2000hsd.google groups.com...
>|| Can you use javascript to activate a php function like so:
>|| <?php
>|| $tab="Tab.gif";
>|| function myfunction($txt)
>|| {
>|| $tab = $txt;
>|| echo($tab);
>|| }
>||
>|| ?>
>|| <div class="backg" onMouseOver="<? php myfunction("Tab3.gif"); ?>"
>|| STYLE="background-image: url(<?=$img_dir?>/images/<?php echo($tab);?
>|| )"
>||
>|| I'm trying to dynamically change the tab button when the when the user
>|| mouse over the tab.
>|
>| php executes on the server. javascript (etc.) executes in the browser on
>the
>| client's pc. this is strickly a javascript endeavor. however, here's how
>i'd
>| think about it...
>|
>|
>| <div mOverSrc="<?= $img_dir ?>/images/Tab3.gif"
>| mResetSrc="<?= $img_dir ?>/images/<?= $tab ?>"
>| onmouseover="this.style.backgroundImage = url(this.mOverSrc);"
>| onmouseout="this.style.backgroundImage = url(this.mResetSrc);"
>| >
>>
>of course you'd want to add in:
>>
>style="background-image:url(<?= $img_dir ?>/images/<?= $tab ?>);"
>>
>so that the default image is displayed in the div when the page loads.
>
I really don't see why people keep pointing out that php is server
side and javascript is client-side, is if that makes it impossible to
implement. JSP is server-side as well, and you can embed JSP scriplets
and what not into javascript just fine. Just because code is server
side doesn't mean it has to execute on the first pass (which seems to
be what php does) .... i.e if I wanted to do something like this in
JSP it would work just like you would expect.
>
Because Java Server Pages are Java - and have absolutely NOTHING to do
with JavaScript (except for the letters "J", "a", "v" and "a".

If you knew that, you wouldn't be posting this crap.
Quote:
<script>
function foo() {
<%
String bar = "foobar";
>
if(bar != null) { %>
//do some javascript stuff
<% } %>
alert(<%=bar%>);
etc.....
}
</script>
>
<input type="button" value="penguins" onclick="foo();"/>
>
Not that I'm saying you should switch to Java webapps especially since
webhosts charge too much to run JBoss, Tomcat, etc and Java Struts or
JSF is much harder to learn and implement. But .....
>
But that's exactly what you are saying. Even though you don't know crap.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Rik Wasmus
Guest
 
Posts: n/a
#7: Aug 30 '07

re: Is this possible?


On Wed, 29 Aug 2007 23:59:45 +0200, Steve <no.one@example.comwrote:
Quote:
"Leoa" <leondria.barbee@gmail.comwrote in message
news:1188422263.801132.124720@r34g2000hsd.googlegr oups.com...
| Can you use javascript to activate a php function like so:
| <?php
| $tab="Tab.gif";
| function myfunction($txt)
| {
| $tab = $txt;
| echo($tab);
| }
|
| ?>
| <div class="backg" onMouseOver="<? php myfunction("Tab3.gif"); ?>"
| STYLE="background-image: url(<?=$img_dir?>/images/<?php echo($tab);?
| )"
|
| I'm trying to dynamically change the tab button when the when the user
| mouse over the tab.
>
php executes on the server. javascript (etc.) executes in the browser on
the
client's pc. this is strickly a javascript endeavor. however, here's how
i'd
think about it...
>
>
<div mOverSrc="<?=
Short_tags, never a good idea....
--
Rik Wasmus

My new ISP's newsserver sucks. Anyone recommend a good one? Paying for
quality is certainly an option.
Steve
Guest
 
Posts: n/a
#8: Aug 30 '07

re: Is this possible?


| I really don't see why people keep pointing out that php is server
| side and javascript is client-side, is if that makes it impossible to
| implement.

i'll keep saying it until the op gets it. and it sounds like you don't quite
have it yet either.


Steve
Guest
 
Posts: n/a
#9: Aug 30 '07

re: Is this possible?


<div mOverSrc="<?=

| Short_tags, never a good idea....

unless you control your server's settings. ;^)


Rik Wasmus
Guest
 
Posts: n/a
#10: Aug 30 '07

re: Is this possible?


On Thu, 30 Aug 2007 10:33:24 +0200, Steve <no.one@example.comwrote:
Quote:
Quote:
><div mOverSrc="<?=
>
| Short_tags, never a good idea....
>
unless you control your server's settings. ;^)
You claim it is a _good_ idea to use it if you control the server?
--
Rik Wasmus

My new ISP's newsserver sucks. Anyone recommend a good one? Paying for
quality is certainly an option.
Steve
Guest
 
Posts: n/a
#11: Aug 30 '07

re: Is this possible?


"Rik Wasmus" <luiheidsgoeroe@hotmail.comwrote in message
news:op.txvcz6k25bnjuv@metallium.lan...
On Thu, 30 Aug 2007 10:33:24 +0200, Steve <no.one@example.comwrote:
Quote:
Quote:
><div mOverSrc="<?=
>
| Short_tags, never a good idea....
>
unless you control your server's settings. ;^)
Quote:
You claim it is a _good_ idea to use it if you control the server?
yes. what's wrong with it?


Satya
Guest
 
Posts: n/a
#12: Aug 31 '07

re: Is this possible?


On Aug 30, 2:17 am, Leoa <leondria.bar...@gmail.comwrote:
Quote:
Can you use javascript to activate a php function like so:
<?php
$tab="Tab.gif";
function myfunction($txt)
{
$tab = $txt;
echo($tab);
>
}
>
?>
<div class="backg" onMouseOver="<? php myfunction("Tab3.gif"); ?>"
STYLE="background-image: url(<?=$img_dir?>/images/<?php echo($tab);?
>
Quote:
)"
>
I'm trying to dynamically change the tab button when the when the user
mouse over the tab.
>
this site has the nav in a module.
>
any suggestions please....
For this look to Javascript. Search in google "javascript image
preload".

http://satya61229.blogspot.com/2007/...avascript.html

Closed Thread