dooper3 Posted December 5, 2006 Share Posted December 5, 2006 I am trying to use js to make a phpBB-style text editor for my website, and i've got it to put in the opening tags when the buttons are clicked, but for some reason it won't put in the closing tags. I think it may be because I am trying to alter the same onclick that calls the function. The code for the function is shown below:[code]function addtags(styling,condition) { if (condition == "open") { document.getElementById(styling).onclick="addtags('"+styling+"','close')" currenttext = document.getElementById('inputarea').innerHTML document.getElementById('inputarea').innerHTML=currenttext+"["+styling+"]" document.getElementById('inputarea').focus() } else { document.getElementById(styling).onclick="addtags('"+styling+"','open')" currenttext = document.getElementById('inputarea').innerHTML document.getElementById('inputarea').innerHTML=currenttext+"[/"+styling+"]" document.getElementById('inputarea').focus() }}</script>[/code]Any ideas? Thanks! Quote Link to comment Share on other sites More sharing options...
fenway Posted December 6, 2006 Share Posted December 6, 2006 So what does it produce? Quote Link to comment Share on other sites More sharing options...
dooper3 Posted December 6, 2006 Author Share Posted December 6, 2006 at the moment it will output the opening [heading] or [b] tags, but not the closing ones. The idea is that the input buttons each have an onclick="('open','heading'). They all start as open, and obviously heading corresponds to whichever button it is. Then when the button is clicked, the function shown before should check whether the brackets are already open by looking for "open" or "close", then do that before changing the onclick to ('close','heading') or whichever was clicked. But at the moment, it will open them, but doesn't like to change them to close (which I guess is down to the fact that the very onclick I am trying to edit is the one that called the function??). Also, it seems to stop the script working for that button aswell - if I try and click it again when the open bit has been done once, nothing happens, but the other buttons will still do the open, then stop working as well. There's no little yellow exclamation mark in IE like their usually is when the browser can't work out the JS. Help! Quote Link to comment Share on other sites More sharing options...
fenway Posted December 16, 2006 Share Posted December 16, 2006 I'm confused... could you post a URL I can see in action? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.