English 中文(简体)
Javascript - Onclick event when and only during pageload
原标题:Javascript - Onclick event happening during and only during page load

我仍然很新,不能发现我犯错的地方。 与Im公司合作建立的基本结构是一套无线电台,还有一套检查箱。 根据收听的无线电塔尔顿,只有一套特定的检查箱才能提供,其余的应残疾/残疾。 允许某个特定无线电台的检查箱通过一个营地阵列。 在我的法典中,排他性选择是指无线电台,而扩大的选择则指检查箱。 我的javascript and php for this行文如下:

window.onload = function(){
    <?php
    for($i = 0; $i < count($students_information); $i++){
        foreach($exclusive_extended_array as $exclusive => $extended){
            echo "$( ".$i."_exclusive_".$exclusive." ).onclick = allow(".$i.",".json_encode($extended).");";
        }
    }
    ?>
}
function allow(i, extended){
    $( [id^=" +i+ Extended"] ).disabled = true;
    for (var j = 0; j < extended.length; j++) {
        alert(extended[j]);
        $(i+"Extended"+extended[j]).disabled = false;
    }
}

在装货页上显示:

<script type="text/javascript">
window.onload = function(){
    $( 0_exclusive_2176 ).onclick = allow(0,[1975]);
    $( 0_exclusive_911 ).onclick = allow(0,[]);
    $( 0_exclusive_795 ).onclick = allow(0,[1973,1975]);
}
function allow(i, extended){
    $( [id^=" +i+ Extended"] ).disabled = true;
    for (var j = 0; j < extended.length; j++) {
        alert(extended[j]);
        $(i+"Extended"+extended[j]).disabled = false;
    }
}
</script>

不幸的是,该守则所结束的是,当页面负荷时,而不是在收音机的某一个县时,使用该笔文字。 我不认为这是一个与要素名称有关的问题(尽管我确实认识到命名风格并不一致,但我并没有完全控制这一点)。 我假定这只是我对法典犯了一个简单的错误,我仍然没有足够的经验可以收集。 谁看一看我干什么错了?

Thank you for your time!

最佳回答

请重新指定您的点击手,如:

$( 0_exclusive_2176 ).onclick = allow(0,[1975]);

发生的情况是:<代码>allow为平整,其收益价值(un defined)被定为活动。 您需要将<代码>onclick设定为一项职能:

$( 0_exclusive_2176 ).onclick = function(){
    allow(0,[1975]);
};

您也可提出<条码>。 恢复职能:

function allow(i, extended){
    return function(){
        $( [id^=" +i+ Extended"] ).disabled = true;
        for (var j = 0; j < extended.length; j++) {
            alert(extended[j]);
            $(i+"Extended"+extended[j]).disabled = false;
        }
    };
}

现在,$(0_ehaus_2176 .onclick=允许(0,[1975]);应当按预期运作。

问题回答

暂无回答




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签