Solved

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

Posted on 2008-10-17
5
139 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 Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

910 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now