Solved

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

Posted on 2008-10-17
5
140 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
  • 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

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…

825 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