|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
php and javascript
i have to put the visible en hidden part in a loop and need some help.
<script type="text/javascript"> <!-- <? $result = mysql_query($sql,$conn) or die("Couldn't do headings query"); while ($row = mysql_fetch_array($result)) { $id = $row['headings_id']; echo ('function showSubm'.$id.'(){ document.getElementById("subMItem'.$id.'").style.visibility="visible"; document.getElementById("subMItem'.$id.'").style.visibility="hidden"; }'); } ?> i was thinking about using a array so that i have to get the if formation from the db 1 time ech time te first loop goes 1 up and the second loop repeat it self till db is empty than it goes back to the first loop.When Submid== subMItemid visibility will beste to visible else hidden. regards. Nookie |
|
#2
|
|||
|
|||
|
I'm not very familiar with JavaScript. But I've tried in the past combining PHP and JavaScript - I could not get it to work very well (or at all actually).
What you're trying to do may not be doable.
__________________
Thomas Jefferson: "Democracy will work only until the political incumbents discover they can perpetuate themselves in office by taxing the industrious to bribe the indolent." |
|
#3
|
||||
|
||||
|
It is most definately possible to combine JAvascript and PHP... just takes a little understanding... remember that whatever PHP you include will be interpretted and the HTML/Javascript output sent to the browser... sometimes its hard to remember that... I've seen some people trying to call PHP functions from Javascript code (in the same document).... that's not possible
However, this doesn't directly relate to Nookie's problem... Nookie, It seems as though you plan on having a number of functions named showSubm1, showSubm2, showSubm3 and so on... I propose a different way of handling this Javascript function... if all you plan on doing is showing a layer, why not simply pass the object as a parameter? Code:
<script type="text/javascript">
// based on your code
function showSubm(item) {
item.style.visibility="visible";
item.style.visibility="hidden";
}
</script>
then, where-ever you're calling it, use (for example) <div onclick="showSubm(this)"> Now, one issue I have with your code is... um... why are you setting the same object visible, then immediately hiding it? Again, I wasn't all that clear on your question... Just simply adding my interpretation of your example =) |
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > php and javascript |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|