Advanced search  

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Pages: [1]   Go Down

Author Topic: [Solved]: Problem at onclick  (Read 2409 times)

0 Members and 1 Guest are viewing this topic.

Crazymodder

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 117
[Solved]: Problem at onclick
« 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:

Code: [Select]
$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
Code: [Select]
<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:
Code: [Select]
document.getElementById('box1').style.visibility = 'visible';
So the full code is:
Code: [Select]
$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
Code: [Select]
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
« Last Edit: August 29, 2008, 06:41:54 pm by Nibbler »
Logged

Crazymodder

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 117
Re: Problem at onclick
« Reply #1 on: August 29, 2008, 12:05:41 pm »

Is there no one who have an idea?
Logged

Nibbler

  • Guest
Re: Problem at onclick
« Reply #2 on: August 29, 2008, 12:10:12 pm »

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

Crazymodder

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 117
Re: Problem at onclick
« Reply #3 on: August 29, 2008, 02:57:29 pm »

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

My Code:
Code: [Select]
$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?

Logged

Nibbler

  • Guest
Re: Problem at onclick
« Reply #4 on: August 29, 2008, 03:29:03 pm »

You need to escape the single quotes:

Code: [Select]
\'box1\'
\'visible\'
Logged

Crazymodder

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 117
Re: Problem at onclick
« Reply #5 on: August 29, 2008, 04:08:32 pm »

Thx Nibbler you are the best now everythink works perfectly;)
Logged
Pages: [1]   Go Up
 

Page created in 0.02 seconds with 20 queries.