/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] onclick display description

Hi All,

I have tried a lot to solve this issue and finding no way I am here ?

The objective is that there are some images and each have their description.Now upon onclick every image the description and the image will be shown separately at a single place.

I have done some coding but stopped at displaying the image description onclick.onclick the images are coming without any problem but their respective description is not coming.Here is the code:

Javascript:

[CODE]<script type=”text/javascript”>

function change(which , t) {
var text = t;
document.getElementById(‘txt’).innerHTML=text;//this is not working
document.getElementById(‘main’).src=”petpic/” + which;
}
</script>[/CODE]

<img id=”main” src=”petpic/<?=$lpr1[‘filename’];?>” width=”400″ height=”300″ border=”0″>

[code=php]<?
$lps=mysql_query(“SELECT * FROM album where pid='{$_GET[‘p’]}'”);
$i = 1;
while($lpr=mysql_fetch_array($lps)){
if($lpr[‘filename’]!=””){?>
<img src=”pic/<?=$lpr[‘filename’];?>” alt=”alt” width=”72″ height=”72″ border=”0″ onclick=”change(‘<?=$lpr[‘filename’];?>,<?=$lpr[‘des’];?>’);” />
<?}else{?>
<img src=”main_images/default.gif” alt=”alt” width=”80″ height=”80″ border=”0″ />
<?}}?>[/code]

Please suggest me how can i display the image description for each onclick each image separately.

Thanks in advance for your co-operation like previous.

Raj

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@scragarOct 12.2007 — try:
[code=php]onclick="change('<?=$lpr['filename'];?>','<?=htmlspecialchars($lpr['des']);?>');" />[/code]
hopefully the quotes and htmlspecial chars should fix your problems ?
Copy linkTweet thisAlerts:
@raj_2006authorOct 13.2007 — Hi m8,

Thanks for your suggestion.yes its working great.Learned a new stuff ?

have one more question

Can't I use <tr id="txt"> instead of using <div id="txt"></div>

innerHTML works with only div's?

Thanks again

Raj
Copy linkTweet thisAlerts:
@scragarOct 13.2007 — works on almost all elements, so yes you can, although I'd recomend not using it on tr's, if only because the temptation is to miss a a closing td somewhere that messes things up.

?
Copy linkTweet thisAlerts:
@raj_2006authorOct 13.2007 — Thanks for your comments again...yeah I got it now 100% ?

Feeling good now...I have one more question..lol but for that I will open a new thread...something similar with this but bit complex.

Regards

Raj
×

Success!

Help @raj_2006 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...