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
Share on other sites

add an id= to your image tags:

<td><img name='but3' id='but3' src='http://pca.x3teamz.net/pic2.php?poke=oddish' onclick='flip(3);'></td>

change your function:

function flip(card)
{
var imgnum = ('but'+card);
document.getElementById(imgnum).src = fliplink;
}

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.