Function call from button to automatic

Joined
Mar 14, 2023
Messages
8
Reaction score
0
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
 
Joined
Sep 4, 2022
Messages
132
Reaction score
16
hello !

did you try with the body onLoad event ?
the onLoad event triggers when the page is loaded.

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

look at 'events' for 'body' :

 
Joined
Mar 14, 2023
Messages
8
Reaction score
0
hello !

did you try with the body onLoad event ?
the onLoad event triggers when the page is loaded.

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

look at 'events' for 'body' :

I did try that but it didn't work. Not sure if it's because it didn't have enough info or not. I see a hidden field below it so I'm thinking that gets passed when the actual button is clicked but I'm unsure. Can that be passed in the body onload call?
 
Joined
Sep 4, 2022
Messages
132
Reaction score
16
I did try that but it didn't work. Not sure if it's because it didn't have enough info or not. I see a hidden field below it so I'm thinking that gets passed when the actual button is clicked but I'm unsure. Can that be passed in the body onload call?

all datas have to be invoke :
it's always "document.getElementById("the_data_id").value" ,
if you don't feed the function with this information, the script will process a "void" data, it leads to a fail of execution.

a "hidden input" is just not in "page display" , but the value in the input field is important.
 
Joined
Mar 14, 2023
Messages
8
Reaction score
0
Fresher,

Thank you for the reply. JavaScript isn't my strength.. so with that said, can I add it to the body load then? Or how would I go about it? Also do I care about the button Id?
 
Joined
Mar 14, 2023
Messages
8
Reaction score
0
im setting the following on the index:
JavaScript:
<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>


JavaScript:
function callLoad() {
    if (top.USE_AJAX) {
        showDB();

        return;
    }

    var cookieString = unescape(getCookieValue("value"));

    var cookieData = parseCookie();

    var url = cookieData["modeVal"];

    var result = confirm("Load data from " + cookieData["matchDetail"]
            + "\n("+ unescape(cookieData["title"]) +")" +
            "\n\nCaution, all data will be lost!");

    if (result == true && top.document.cookie) {
        window.open("../modes/" + url + "?load", 'bottom');
    }

}

JavaScript:
function showDB() {
    if(window.location.protocol == "file:") {
        alert("For security reasons, browsers do not store local website");

        return;
    }

    window.open("../data/login.php?current_title="+ top.GLOBALS["title"] + "&current_data=" + buildCookie()    + "&referrer=" +  window.location.protocol + "/" + window.location.pathname);

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,961
Messages
2,570,131
Members
46,689
Latest member
liammiller

Latest Threads

Top