coppermine-gallery.com/forum

Support => cpg1.4.x Support => Older/other versions => cpg1.4 miscellaneous => Topic started by: Crazymodder on August 27, 2008, 10:30:48 AM

Title: [Solved]: Problem at onclick
Post by: Crazymodder on August 27, 2008, 10:30:48 AM
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
Title: Re: Problem at onclick
Post by: Crazymodder on August 29, 2008, 12:05:41 PM
Is there no one who have an idea?
Title: Re: Problem at onclick
Post by: Nibbler on August 29, 2008, 12:10:12 PM
You're missing the ending double quotes for your onclick attribute.
Title: Re: Problem at onclick
Post by: Crazymodder on August 29, 2008, 02:57:29 PM
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?

Title: Re: Problem at onclick
Post by: Nibbler on August 29, 2008, 03:29:03 PM
You need to escape the single quotes:


\'box1\'
\'visible\'
Title: Re: Problem at onclick
Post by: Crazymodder on August 29, 2008, 04:08:32 PM
Thx Nibbler you are the best now everythink works perfectly;)