[Solved]: Problem at onclick [Solved]: Problem at onclick
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

[Solved]: Problem at onclick

Started by Crazymodder, August 27, 2008, 10:30:48 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Crazymodder

Hello every one i have some boxes with bbcode under each image but now I want to show up a litte box under the textarea if you click into the textbox.
My Codeidea:

$info['Show Pic<br>to a friend']='<textarea type="text" name="text" rows=2 cols=60 onclick="focus();select();copy(this.value); readonly="readonly">'.$CONFIG["ecards_more_pic_target"] . (substr($CONFIG["ecards_more_pic_target"], -1) == '/' ? '' : '/').basename($_SERVER['PHP_SELF'])."?pos=-$CURRENT_PIC_DATA[pid]".'</textarea><div align="center" id="box1" style="border: 1px solid #FF0042; visibility:hidden; background-color: #FFE7ED">My Text</div>';


So this <div align="center" id="box1" style="border: 1px solid #FF0042; visibility:hidden; background-color: #FFE7ED">My Text</div>'; is a little box and should be only show if you click on the textarea. So you have to set visibility:visible;

My Idea was to put that code behind the onclick of the textarea:
document.getElementById('box1').style.visibility = 'visible';

So the full code is:
$info['Show Pic<br>to a friend']='<textarea type="text" name="text" rows=2 cols=60 onclick="focus();select();copy(this.value); document.getElementById('box1').style.visibility = 'visible'; readonly="readonly">'.$CONFIG["ecards_more_pic_target"] . (substr($CONFIG["ecards_more_pic_target"], -1) == '/' ? '' : '/').basename($_SERVER['PHP_SELF'])."?pos=-$CURRENT_PIC_DATA[pid]".'</textarea><div align="center" id="box1" style="border: 1px solid #FF0042; visibility:hidden; background-color: #FFE7ED">My Text</div>';


But the problem is if I add this code
document.getElementById('box1').style.visibility = 'visible'; thinks like focus(); select(); copy(this.value); doesn't work.
I hope you can help me and tell me how I have to change te code.

Thx
Best Regards
Crazymodder

Crazymodder

Is there no one who have an idea?

Nibbler

You're missing the ending double quotes for your onclick attribute.

Crazymodder

I have add the " at the end but I have an error

My Code:
$info['Bild einem<br>Freund zeigen']='<textarea type="text" name="text" rows="2" cols="60" onclick="focus();select();copy(this.value);
document.getElementById('box1').style.visibility = 'visible';" readonly="readonly">'.$CONFIG["ecards_more_pic_target"] .
(substr($CONFIG["ecards_more_pic_target"], -1) == '/' ? '' : '/').basename($_SERVER['PHP_SELF'])."?pos=-$CURRENT_PIC_DATA[pid]".'</textarea><div
align="center" id="box1" style="border: 1px solid #FF0042; visibility:hidden; background-color: #FFE7ED">Code kopiert</div>';


The ErorrMessage is:
http://layertest.la.funpic.de/displayimage.php?album=random&cat=0&pos=-4#
if you change 'visible' to "visible" you get no error but than it didn't work because you must use 'visible' do you have any idea?


Nibbler

You need to escape the single quotes:


\'box1\'
\'visible\'

Crazymodder

Thx Nibbler you are the best now everythink works perfectly;)