473,320 Members | 1,853 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Is this possible?

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.

this site has the nav in a module.

any suggestions please....

Aug 29 '07 #1
11 1701
Yes, it's possible, but not in the way that you are thinking. You
should try looking into AJAX.

Leoa wrote:
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.

this site has the nav in a module.

any suggestions please....
Aug 29 '07 #2

"Leoa" <le*************@gmail.comwrote in message
news:11**********************@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);"
>
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.
Aug 29 '07 #3

"Steve" <no****@example.comwrote in message
news:V_*************@newsfe12.lga...
|
| "Leoa" <le*************@gmail.comwrote in message
| news:11**********************@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.
Aug 29 '07 #4
On Aug 29, 5:04 pm, "Steve" <no....@example.comwrote:
"Steve" <no....@example.comwrote in message

news:V_*************@newsfe12.lga...
|| "Leoa" <leondria.bar...@gmail.comwrote in message

|news:11**********************@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 .....

Aug 30 '07 #5
Mo******@gmail.com wrote:
On Aug 29, 5:04 pm, "Steve" <no....@example.comwrote:
>"Steve" <no....@example.comwrote in message

news:V_*************@newsfe12.lga...
|| "Leoa" <leondria.bar...@gmail.comwrote in message

|news:11**********************@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.
<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.
js*******@attglobal.net
==================
Aug 30 '07 #6
On Wed, 29 Aug 2007 23:59:45 +0200, Steve <no****@example.comwrote:
"Leoa" <le*************@gmail.comwrote in message
news:11**********************@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.
Aug 30 '07 #7
| 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.
Aug 30 '07 #8
<div mOverSrc="<?=

| Short_tags, never a good idea....

unless you control your server's settings. ;^)
Aug 30 '07 #9
On Thu, 30 Aug 2007 10:33:24 +0200, Steve <no****@example.comwrote:
><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.
Aug 30 '07 #10
"Rik Wasmus" <lu************@hotmail.comwrote in message
news:op***************@metallium.lan...
On Thu, 30 Aug 2007 10:33:24 +0200, Steve <no****@example.comwrote:
><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?
yes. what's wrong with it?
Aug 30 '07 #11
On Aug 30, 2:17 am, Leoa <leondria.bar...@gmail.comwrote:
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.

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

Aug 31 '07 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Julia Briggs | last post by:
I am struggling to create a PHP function that would take a specified image (JPG, GIF or PNG) from a link, and resize it down to a thumbnail so it will always fit in a 200x250 space. I am hoping...
36
by: rbt | last post by:
Say I have a list that has 3 letters in it: I want to print all the possible 4 digit combinations of those 3 letters: 4^3 = 64 aaaa
20
by: CHIN | last post by:
Hi all.. here s my problem ( maybe some of you saw me on other groups, but i cant find the solution !! ) I have to upload a file to an external site, so, i made a .vbs file , that logins to...
7
by: Andrzej | last post by:
Is it possible to call a function which name is given by a string? Let assume that I created a program which call some functions for example void f1(void), void f2(void), void f3(void). ...
2
by: Bhupesh Naik | last post by:
This is a query regarding my problem to make a spell and grammar check possible in text area of a web page. We have aspx pages which are used to construct letters. The browser based screens...
1
by: AAA | last post by:
hi, I'll explain fastly the program that i'm doing.. the computer asks me to enter the cardinal of a set X ( called "dimX" type integer)where X is a table of one dimension and then to fill it...
25
by: Piotr Nowak | last post by:
Hi, Say i have a server process which listens for some changes in database. When a change occurs i want to refresh my page in browser by notyfinig it. I do not want to refresh my page i.e....
4
by: RSH | last post by:
Okay my math skills aren't waht they used to be... With that being said what Im trying to do is create a matrix that given x number of columns, and y number of possible values i want to generate...
7
by: Robert S. | last post by:
Searching some time now for documents on this but still did not find anything about it: Is it possible to replace the entry screen of MS Office Access 2007 - that one presenting that default...
14
by: bjorklund.emil | last post by:
Hello pythonistas. I'm a newbie to pretty much both programming and Python. I have a task that involves writing a test script for every possible combination of preference settings for a software...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.