Solved

trying to use an image to use as a textwrap but just refreshes page?

Posted on 2008-10-17
5
141 Views
Last Modified: 2010-04-21
ok for my bbcode i want to enter images... so for this iv came up with this html/javascript  (sown below)

but the problem is when ever i click on the image.. it enters it into the textbox but then refreshes the page :S how comes??

as can be seen by the code there is a toggle area to which you can view the smilies by clicking a button or not!


function initialise() {
var element = document.getElementById('element-id');
 
if (element && element.style)
element.style.display = 'none';
}
 
function toggleDisplay(element) {
var style;
 
if (typeof element == 'string')
element = document.getElementById(element);
if (element && (style = element.style))
style.display = (style.display == 'none') ? '' : 'none';
}
 
if (!document.getElementById)
document.getElementById = function() {return null;};
 
<input type="button" value="Smilies" onclick="toggleDisplay('element-id');">
<div id="element-id" style="display: none;">
<INPUT TYPE="image" SRC="http://www.runningprofiles.com/emoticons/smiley.gif" name='smile' onclick='wrapText(document.getElementById(&#39;inputforum&#39;),&#39;:&#39;,&#39;)&#39;);'>
</div>

Open in new window

0
Comment
Question by:runnerjp
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 7

Expert Comment

by:bluV11t
ID: 22738753
Could you post code for the wrapText function?
0
 

Author Comment

by:runnerjp
ID: 22738796
i did its hear


onclick='wrapText(document.getElementById(&#39;inputforum&#39;),&#39;:&#39;,&#39;)&#39;);'>

Open in new window

0
 
LVL 7

Expert Comment

by:bluV11t
ID: 22738810
No that's just the call to wrapText. I need the actual function like

function wrapText(){
//some code here

}
0
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 500 total points
ID: 22738818
input type=image is a submit button
and you use the wrong quotes
Instead do

<a href="#" title="smile"
onclick="wrapText(document.getElementById('inputforum'),':',')'); return false"><img 
src="http://www.runningprofiles.com/emoticons/smiley.gif" border="0"></a>

Open in new window

0
 

Author Closing Comment

by:runnerjp
ID: 31507071
thanks worked great!!!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
This article discusses how to create an extensible mechanism for linked drop downs.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question