Solved

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

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to dynamically set the form action using jQuery.
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)

708 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

12 Experts available now in Live!

Get 1:1 Help Now