MyBB Community Forums

Full Version: Unique postbit button with javascript
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
With help from ranjani we made two buttons for the post bit template, with the first button you're able to open all spoilers on the page and with the second you're able to close all spoilers on the page. The code is:
<a href="javascript:var%20btn=document.getElementsByTagName('input');for(var%20i%20in%20btn){if(btn[i].value==%22Show%22){btn[i].click();}else{}}"><img src="http://upit.cc/i/89d0219f.png" alt="Open all spoilers" title="Open all spoilers"></a><a href="javascript:var%20btn=document.getElementsByTagName('input');for(var%20i%20in%20btn){if(btn[i].value==%22Hide%22){btn[i].click();}else{}}"><img src="http://upit.cc/i/43b973a1.png" alt="Close all spoilers" title="Close all spoilers"></a>

What I need is help integrating both buttons the same way MyBB does their "multiquote", it's one button that changes the image on click and does the opposite on click. I need this, make it so you click it once all images open and the images changes to the red one, user clicks again and the second code functions where everything closes and the blue buttons goes back.
it can be single button for chrome AND two buttons for firefox ; code is yet to be improved ...
{ other browsers are not considered at present }
But how is MyBB able to fit everything into one button? Let's do what MyBB does with multi quote
The multiquote button uses cookies and javascript. so when you click the button a cookie is set to include the PID. then when you reply, it looks for the cookie and parses the PIDs an quotes them
Well right now I'm not using "multiquote" on my forum and will probably never use it. Can't I just replace the function multi quote currently performs to the javascript above?
It could work.... I don't know JS very well but it seems like it would work.
Bump, I still need this. I need the button to have two images that change on click and function two different codes.