MyBB Community Forums

Full Version: Javascript Help
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

I'm trying to add a new button and javascript to the editor, I've followed the "Adding button to Editor" tutorial, but I want the button to show more than one text box ie Title, Price, Image, URL and text. I have the following code but getting stuck, I have very limited knowledge of javascript.

insertDeal: function()
    {
        selectedText = this.getSelectedText($(this.textarea));
        deal = prompt("Please enter a name of the game, hardware or accessory.", "");
 
        if(title)
        {
            if(!selectedText)
            {
                text = prompt("Enter name of item.", "");
            }
            else
            {
                this.performInsert("[deal="+title+"][/deal]", "", true, false);
            }

         if(price)
        {
            if(!selectedText)
            {
                text = prompt("Enter price. ie 9.99", "0.00");
            }
            else
            {
                this.performInsert("[deal="+title+" "+price+"][/deal]", "", true, false);
            }

        if(cover)
        {
            if (!selectedText)
            {
                text = prompt("Enter image of item.", "http://");
            }
            else
            {
                this.performInsert("[deal="+title+" "+price+" "+cover+"][/deal]", "", true, false);
            }

        if(url)
        {
            if(!selectedText)
            {
                text = prompt("Enter link to deal.", "http://");
            }
            else
            {
                this.performInsert("[deal="+title+" "+price+" "+cover+" "+url+"][/deal]", "", true, false);
            }

        if(from)
        {
            if(!selectedText)
            {
                text = prompt("Enter where you can get this deal. ie Argos, Tesco.", "");
            }
            else
            {
                this.performInsert("[deal="+title+" "+price+" "+cover+" "+url+"]"+from+"[/deal]", "", true, false);
            }
        }
    },


So if someone can help I would be very grateful Smile