Reply to Re: Is this possible?

Your name:

Reply:


Posted by Morlaath on 08/30/07 03:25

On Aug 29, 5:04 pm, "Steve" <no....@example.com> wrote:
> "Steve" <no....@example.com> wrote in message
>
> news:V_lBi.82$tb5.58@newsfe12.lga...
> || "Leoa" <leondria.bar...@gmail.com> wrote in message
>
> |news:1188422263.801132.124720@r34g2000hsd.googlegroups.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 .....

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация