Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

JavaScript changing function call from button to automatic

This may sound like a stupid question but im just not great yet at javascript

so currently the page does this:
HTML:
<body onload="checkLoad(); showConfig(); checkOptions(); testAjax();">


<table class="menuGroup">
            <tr>
                <td width="100%" align="center">
                    Title: <input type="text" id="title" size="32" value="My Tournament Name" onchange="updateTitle();" readonly> 
                    <!-- <input type="button" value="End Config" onclick="showTitle();">  -->
                </td>
            </tr>
            <tr>
                                                                  <td><input type="button" id="load" value="Show List" onclick="callLoad()" DISABLED></td>
                                                                 <input type="hidden" id="complete" CHECKED/> 
                                                          
            </tr>

            </table>

is there a way i can change this from having to click the button for "Show List" to just having it do it when the page loads? Any help or suggestions would be appricated
 
Why not just add callLoad(); to the list of function calls in the body onload ?
i tried that but it didnt do anything. i think it has to do with the hidden field. also not sure if i have to do anyhing with the button too. im guessing i just need to somehow pass the hidden field but not sure how if its in the body onload. any suggestions?
 
If that function works when you click on the "Show List" button (which I think is what you implied) I see no reason why it would not work when called from the onload trigger. Unless it somehow assumes things about the event target. When you say "it does not didn't do anything" what do you mean ? Was it not being called at all ? Or was it being called but stalled on an error ? Please be precise. Did you check the console log for errors ?
 
If that function works when you click on the "Show List" button (which I think is what you implied) I see no reason why it would not work when called from the onload trigger. Unless it somehow assumes things about the event target. When you say "it does not didn't do anything" what do you mean ? Was it not being called at all ? Or was it being called but stalled on an error ? Please be precise. Did you check the console log for errors ?
i get a blank page. sorry if this sounds like a dumb question, where do i see the console log? do i have to code for that? i dont see its on my server
 
i get a blank page. sorry if this sounds like a dumb question, where do i see the console log? do i have to code for that? i dont see its on my server
I meant to say Console window, not console log. Press F12 in your browser to bring up the debugger. One of the tabs is called Console. Click it, refresh your page and do your stuff, and see if anything comes up in the Console.
For my understanding, does or doesn't it work correctly when you click that "Show List" button ?
 
I meant to say Console window, not console log. Press F12 in your browser to bring up the debugger. One of the tabs is called Console. Click it, refresh your page and do your stuff, and see if anything comes up in the Console.
For my understanding, does or doesn't it work correctly when you click that "Show List" button ?
yes, the button works...

here is the output on console

warning
This page is in Almost Standards Mode. Page layout may be impacted. For Standards Mode use “<!DOCTYPE html>”.
error:
Uncaught TypeError: top.DEFAULTS is undefined
<anonymous>data.js:25
warning:
Scripts may not close windows that were not opened by script.
 
But when do you get this output ? When you click the button, which you say works ? In that case the messages are probably harmless, but I'd follow up on then anyway. Never, ever, leave warning or errors hanging around if you can help it.
Or do you get this output when callLoad(); is executed from the body onload (which you say "isn't doing anything") ?
Just trying to understand if these are related to your problem or not.
 
But when do you get this output ? When you click the button, which you say works ? In that case the messages are probably harmless, but I'd follow up on then anyway. Never, ever, leave warning or errors hanging around if you can help it.
Or do you get this output when callLoad(); is executed from the body onload (which you say "isn't doing anything") ?
Just trying to understand if these are related to your problem or not.
1st, thank you for helping me. i really appreciate it. it works correctly when i go to this page and click the button. what i want is to skip the step of clicking the button so that it will load directly. i dont like the extra step of just clicking the button. here is the page with the button:
Code:
<?php
session_start();


unset($_SESSION["tourny"]);
unset($_SESSION["userId"]);
unset($_SESSION['nick']);
$_SESSION['nick'] = "[email protected]";
$_SESSION["user"] = "guest";
$_SESSION["userId"] = $_GET["userID"];
$_SESSION["tourny"] = $_GET["tourny"];
?>

<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"/>
<meta name="keywords" lang="en-us" content="javascript, tournament, sheet, foosball">
<meta name="keywords" lang="en" content="javascript, tournament, sheet, foosball">

<title>tournament brackets</title>

<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon">
<link rel="icon" href="images/favicon.ico" type="image/x-icon">

<script language="javascript">

    var FRAME_BIG = 190;
    var FRAME_SMALL = 80;
    
    var GLOBALS = new Array();
    
    var DEFAULTS = new Array();
    
    var INPUTS = new Array();
    
    DEFAULTS["teams"] = 8;
    DEFAULTS["sets"]  = 1;
    DEFAULTS["groups"]  = 1;
    DEFAULTS["modeVal"] = "dko.html";
    DEFAULTS["modeTxt"] = "Double Elimination";
    DEFAULTS["title"] = "Tournament Name";
    DEFAULTS["shuffleLooser"] = true;
    
    var FILL_FROM_GRP = false;
    
    var LOAD = true;
    
    var USE_AJAX = true;



</script>

</head>

<frameset rows="70,*" id="frames">
    <!-- <frame name="config" src="pages/config_read.html" scrolling=no noresize /> -->
       <frame name="config" src="pages/config_read.html"  scrolling=no noresize />

    <frame name="bottom" src="modes/ko_readonly.html?8&1" noresize />
</frameset>

<head>
<link rel='stylesheet' id="style_bottom" href='../styles/default/main.css' type='text/css' />
<link rel='stylesheet' href='../styles/common.css' type='text/css' />
<script type='text/javascript' src='../scripts/autocomplete.js'></script>

<script type='text/javascript' src='scripts/cookie.js'></script>
<script type='text/javascript' src='scripts/layout.js'></script>
<script type='text/javascript' src='scripts/data.js'></script>
<script type='text/javascript' src='scripts/input.js'></script>

<script type='text/javascript' src='scripts/match_read.js'></script>
<script type='text/javascript' src='scripts/table.js'></script>


</head>

<body onload="showConfig(); checkLoad(); checkOptions(); testAjax();" >


<div id="titleSection">
    <table width="100%" height="56">
    <tr>
        <td>
            <img src="../../images/logo.png" />
        </td>
        <td width="100%">
            <span id="titletext"></span>
        </td>
        <td><input type="button" onclick="showConfig();" value="Config"></td>
    </tr>
    </table>
</div>

<div id="cookieSection" height="166" align="center">
    <table height="100%">
    <tr>
        <td width="100%" colspan="4" ailgn="center">
            Copy the cookie into a text file to save several tournaments permanently.<br>To load, simply copy the cookie back!
        </td>
    </tr>
    <tr>
        <td width="100%" colspan="4">
            <textarea id="cookieInput" rows="5" cols="100"></textarea>
        </td>
    </tr>
    <tr>
        <td>
            <input type="button" value="Clear" onclick="setCookie();"/>
        </td>
        <td>
            <input type="button" value="Back" onclick="showConfig();"/>
        </td>
        <td width="100%">&nbsp;
        </td>
    </tr>
    </table>
</div>

<div id="loadingSection" height="100" align="center">
    <table align="center" height="100%">
    <tr>
        <td ailgn="center" class="loadingText">
            Loading Tournament... <br>
            <img src="../images/loader.gif" />
        </td>
    </tr>
    </table>
</div>

<div id="configSection">
<table id="configTable">

    <tr>
        <td>
            <table class="menuGroup">
            <tr>
            
                                                  <td>Type:</td>
                <td colspan="3">
                    <select id="Mode" onchange="checkOptions();" readonly>
                      <option value="ko_readonly.html" SELECTED>Single Elimination</option>
                      <option value="dko.html">Double Elimination</option>
                                                                      <option value="swiss.html">POOL PLAY ??? </option>
                      <option value="grp.html">Round Robbin</option>
                    </select>
                                                                  
                </td>
                                  
            </tr>
            <tr>
                <td>Teams: </td>
                <td><input type="text" id="teams" size="2" MAXLENGTH="2" value="8" readonly></td>
            </tr>
            <tr id="groupOptions">
                <td>Group: </td>
                <td><input type="text" id="groups" size="2" MAXLENGTH="2" value="1" readonly></td>
            </tr>
            <tr>
                <td>Size: </td>
                <td><input type="text" id="sets" size="2" MAXLENGTH="1" value="1" readonly></td>
            </tr>
                 <!--
                                                 <tr id="loserOptions">
                <td>Losing Round</td>
                <td><input type="checkbox" id="shuffle"/></td>
            </tr>
            <tr valign="top" heigth="100%">
                 <td><input type="button" value="Make Bracket" onclick="changeTeams()"></td>
                 <td><input type="button" value="CSV Export"  onclick="csv()""></td>
            </tr>
                                       -->
            </table>
        </td>
        <td valign="top">
            <table class="menuGroup">
            <tr>
                <td width="100%" align="center">
                    Title: <input type="text" id="title" size="32" value="My Tournament Name" onchange="updateTitle();" readonly>
                    <!-- <input type="button" value="End Config" onclick="showTitle();">  -->
                </td>
            </tr>
            <tr>
                                                                  <td align="center"><input type="button" id="load" value="Load Bracket" onclick="callLoad()" DISABLED></td>
                                                                 <input type="hidden" id="complete" CHECKED/>
                                                          
            </tr>
                                                
            </table>
        </td>

    </tr>
</table>
</div>



<div id="dimmer">&nbsp;</div>

<div id="seperator">
Single Elimation
</div>

<script>

init("Single KO");

createKoTable(getTeamCount(), getSets());
</script>

<div id="seperator">
Thrid place
</div>

<script>
//createThirdPlace(getTeamCount(), getSets());
//load();
//createFooter2();

</script>

</body>

</html>



here is pages/config_read.html :
HTML:
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"/>
<title></title>

<script type='text/javascript' src='../scripts/cookie.js'></script>
<script type='text/javascript' src='../scripts/layout.js'></script>
<script type='text/javascript' src='../scripts/dataRead.js'></script>
<script type='text/javascript' src='../scripts/input.js'></script>
<script type='text/javascript' src='../scripts/ajax.js'></script>

<link rel='stylesheet' id="style_top" href='../styles/default/config.css' type='text/css' />

<script language="javascript">
    function updateTitle()
               {
        top.GLOBALS["title"] = document.getElementById("title").value;
    }


</script>
</script>

</head>

<body onload="checkLoad(); showConfig(); checkOptions(); testAjax();">

<div id="titleSection">
    <table width="100%" height="56">
    <tr>
        <td>
            <img src="../../images/logo.png" />
        </td>
        <td width="100%">
            <span id="titletext"></span>
        </td>
        <td><input type="button" onclick="showConfig();" value="Config"></td>
    </tr>
    </table>
</div>

<div id="cookieSection" height="166" align="center">
    <table height="100%">
    <tr>
        <td width="100%" colspan="4" ailgn="center">
            Copy the cookie into a text file to save several tournaments permanently.<br>To load, simply copy the cookie back!
        </td>
    </tr>
    <tr>
        <td width="100%" colspan="4">
            <textarea id="cookieInput" rows="5" cols="100"></textarea>
        </td>
    </tr>
    <tr>
        <td>
            <input type="button" value="Clear" onclick="setCookie();"/>
        </td>
        <td>
            <input type="button" value="Back" onclick="showConfig();"/>
        </td>
        <td width="100%">&nbsp;
        </td>
    </tr>
    </table>
</div>

<div id="loadingSection" height="100" align="center">
    <table align="center" height="100%">
    <tr>
        <td ailgn="center" class="loadingText">
            Loading Tournament... <br>
            <img src="../images/loader.gif" />
        </td>
    </tr>
    </table>
</div>

<div id="configSection">
<table id="configTable">

    <tr>
        <td>
            <table class="menuGroup">
            <tr>
            
                                                  <td>Type:</td>
                <td colspan="3">
                    <select id="Mode" onchange="checkOptions();" readonly>
                      <option value="ko_readonly.html" SELECTED>Single Elimination</option>
                      <option value="dko.html">Double Elimination</option>
                                                                      <option value="swiss.html">POOL PLAY ??? </option>
                      <option value="grp.html">Round Robbin</option>
                    </select>
                                                                  
                </td>
                                  
            </tr>
            <tr>
                <td>Teams: </td>
                <td><input type="text" id="teams" size="2" MAXLENGTH="2" value="8" readonly></td>
            </tr>
            <tr id="groupOptions">
                <td>Group: </td>
                <td><input type="text" id="groups" size="2" MAXLENGTH="2" value="1" readonly></td>
            </tr>
            <tr>
                <td>Size: </td>
                <td><input type="text" id="sets" size="2" MAXLENGTH="1" value="1" readonly></td>
            </tr>
                 <!--
                                                 <tr id="loserOptions">
                <td>Losing Round</td>
                <td><input type="checkbox" id="shuffle"/></td>
            </tr>
            <tr valign="top" heigth="100%">
                 <td><input type="button" value="Make Bracket" onclick="changeTeams()"></td>
                 <td><input type="button" value="CSV Export"  onclick="csv()""></td>
            </tr>
                                       -->
            </table>
        </td>
        <td valign="top">
            <table class="menuGroup">
            <tr>
                <td width="100%" align="center">
                    Title: <input type="text" id="title" size="32" value="My Tournament Name" onchange="updateTitle();" readonly>
                    <!-- <input type="button" value="End Config" onclick="showTitle();">  -->
                </td>
            </tr>
            <tr>
                                                                  <td align="center"><input type="button" id="load" value="Load Bracket" onclick="callLoad()" DISABLED></td>
                                                                 <input type="hidden" id="complete" CHECKED/>
                                                          
            </tr>
                                                
            </table>
        </td>

    </tr>
</table>
</div>

</body>

</html>


here is modes/ko_readonly.html:
HTML:
<head>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"/>
<title>Single Elimination</title>

<link rel='stylesheet' id="style_bottom" href='../styles/default/main.css' type='text/css' />
<link rel='stylesheet' href='../styles/common.css' type='text/css' />
<script type='text/javascript' src='../scripts/autocomplete.js'></script>

<script type='text/javascript' src='../scripts/cookie.js'></script>
<script type='text/javascript' src='../scripts/layout.js'></script>
<script type='text/javascript' src='../scripts/data.js'></script>
<script type='text/javascript' src='../scripts/input.js'></script>

<script type='text/javascript' src='../scripts/match_read.js'></script>
<script type='text/javascript' src='../scripts/table.js'></script>
</head>

<body onload="showConfig();">

<div id="dimmer">&nbsp;</div>

<div id="seperator">
Single Elimation
</div>

<script>
init("Single KO");

createKoTable(getTeamCount(), getSets());
</script>

<div id="seperator">
Thrid place
</div>

<script>
createThirdPlace(getTeamCount(), getSets());
load();
createFooter();
</script>

</body>
</html>
 
I am quite surprised that anything works at all here, as each of these three html files is rife with errors and warnings. My advice is to go to the W3C online HTML validator, check each of these files, and understand and eliminate all of the errors. It's a tedious but necessary (and sometimes humbling) process. As long as the HTML has errors, I see little point in helping. For good measure also check the CSS in the W3C online CSS validator.
 
I am quite surprised that anything works at all here, as each of these three html files is rife with errors and warnings. My advice is to go to the W3C online HTML validator, check each of these files, and understand and eliminate all of the errors. It's a tedious but necessary (and sometimes humbling) process. As long as the HTML has errors, I see little point in helping. For good measure also check the CSS in the W3C online CSS validator.
It seems to work just fine when clicking the button. Maybe it's the difference when all include files are present ??
 

New Threads

Latest posts

Buy us a coffee!

Back
Top Bottom