www.webdeveloper.com
Results 1 to 5 of 5

Thread: innerHTML - Center buttons

  1. #1
    Join Date
    Jun 2014
    Posts
    3

    innerHTML - Center buttons

    I'm trying to centralize buttons on an interface which uses the innerHTML property

    The interface looks like this: http://i.imgur.com/JVD0F9I.png

    Here's the code as to where I assume the buttons call from:

    Code:
    function fightdelay(tstatus) {
        if (lastaction != "m" && lastaction != "t" && lastaction != "o" && lastaction != "v" && lastaction != "k2" && lastaction != "k3" && lastaction != "rf" && lastaction != "q") {
            if (mx == 1) {
                top.toiminta.attb.innerHTML = "<input type=button value=' use weapon ' id='btn_attack' name='btn_attack' onclick='top.fightAction();'>";
                top.toiminta.casb.innerHTML = "<input type=button value=' cast spell ' id='btn_cast' name='btn_cast' onclick='top.castAction();'>";
    			
            }
            top.toiminta.nefb.innerHTML = "<input type=button value=' new fight ' onclick='top.newFightAction();'>";
        }
    }
    
    function delNF() {
        top.toiminta.nefb.innerHTML = "<input type=button value=' new fight ' onclick='void(#);'>";
    }
    
    function s_c() {
        top.chat.document.msg.btn_chat.disabled = true;
    }
    
    function getRandomButtonText(nbr) {
        return "...";
    }
    
    function getRandomNum() {
        var rndNum = Math.random()
        rndNum = parseInt(rndNum * 1000);
        rndNum = (rndNum % 94) + 33;
        return rndNum;
    }
    Take into account that this is from a game from early 2001

  2. #2
    Join Date
    Mar 2011
    Posts
    1,145
    Without knowing what the surrounding HTML mark-up looks like, it's impossible to give you a definitive answer. It would be best to control the display in your stylesheet.

    You could try enclosing the <input> tags in a <p>aragraph like: "<p style="text-align:center;"></p>", but whether or not it gives you the result you want is anyone's guess.
    Rick Trethewey
    Rainbo Design

  3. #3
    Join Date
    Jun 2014
    Posts
    3
    Quote Originally Posted by rtrethewey View Post
    Without knowing what the surrounding HTML mark-up looks like, it's impossible to give you a definitive answer. It would be best to control the display in your stylesheet.

    You could try enclosing the <input> tags in a <p>aragraph like: "<p style="text-align:center;"></p>", but whether or not it gives you the result you want is anyone's guess.
    Code:
    function f() {
    		return "<center><table CELLSPACING=0 CELLPADDING=0 width='300' cols=2><tr>"+
    			"<form method=POST name=fightForm action=battle4.php target=arvot><td><center><input type=hidden name=a value='f'>"+lp()+"<span id=attb></span></td></form>"+
    			"<form method=POST name=castForm action=battle4.php target=arvot><td><center><input type=hidden name=a value='c'>"+lp()+"<span id=casb></span></td></form></tr><tr><td colspan=2><center>";
    	}

  4. #4
    Join Date
    May 2014
    Posts
    1,051
    You have FORM someplace you can't put form (around a TD inside a TR), tags like CENTER and attributes like TARGET that have no business on any site written after 1997... span for who knows what, incomplete markup if using modern (aka post 1997) coding practices...

    I'd really have to see a LOT more than just these little snippets, but whatever it is you're attempting to do this isn't how you do it... unless this was written prior to somewhere around 2001.

    ... as evidenced by using innerHTML instead of manipulating the DOM.
    Java is to JavaScript as Ham is to Hamburger.

  5. #5
    Join Date
    Jun 2014
    Posts
    3
    Quote Originally Posted by deathshadow View Post
    You have FORM someplace you can't put form (around a TD inside a TR), tags like CENTER and attributes like TARGET that have no business on any site written after 1997... span for who knows what, incomplete markup if using modern (aka post 1997) coding practices...

    I'd really have to see a LOT more than just these little snippets, but whatever it is you're attempting to do this isn't how you do it... unless this was written prior to somewhere around 2001.

    ... as evidenced by using innerHTML instead of manipulating the DOM.
    Well, here's everything apart from the images and includes..

    https://www.shimlar.org/files.rar

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles