Jump to content

variables


desithugg

Recommended Posts

<head>
<script language='javascript'>
fliplink = 'http://pca.x3teamz.net/pic2.php?poke=zapdos';
function flip(card)
{
var imgnum = ('but'+card);
document.imgnum.src = fliplink;
}
</script>
</head>
<body>
<table border='1'>
<tr>
<td><img name='but0' src='http://pca.x3teamz.net/pic2.php?poke=oddish' onclick='flip(0);'></td>
<td><img name='but1' src='http://pca.x3teamz.net/pic2.php?poke=oddish' onclick='flip(1);'></td>
<td><img name='but2' src='http://pca.x3teamz.net/pic2.php?poke=oddish' onclick='flip(2);'></td>
<td><img name='but3' src='http://pca.x3teamz.net/pic2.php?poke=oddish' onclick='flip(3);'></td>
<td><img name='but4' src='http://pca.x3teamz.net/pic2.php?poke=oddish' onclick='flip(4);'></td>
</tr>
</table>
</body>

Umm lets say you click one of the images and the function flip(3); is called for

<script language='javascript'>
fliplink = 'http://pca.x3teamz.net/pic2.php?poke=zapdos';
function flip(card)
{
var imgnum = ('but'+card);
document.imgnum.src = fliplink;
}
</script>

Now here the card variable holds the value 3 and than I use that to make the variable imgnum which now holds the value 'but3' I want to update the image link with the name 'but3' or in othercases whatever value the variable imgnum has

Umm might be a bit confusing im not sure how to word it really.

 

Link to comment
https://forums.phpfreaks.com/topic/45828-variables/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.