-1

onclick関数がクリックされたときに他のオブジェクトを表示したいと思います。そのボタンをクリックすると、1つのオブジェクトが非表示になり、他の2つのオブジェクトが表示されます。すでにstyle.visibilityをvisibleに設定しています。しかし、showtwoオブジェクトは機能しません。

サンプルの更新:

<input type="submit" id="show" name="show" value="show" onclick="RemoveDoc(); document.getElementById('docname').style.visibility='hidden'; document.getElementById('browse').style.visibility='visible'; return false;" />
//browse input
<input type ="file" name="browse" id="browse">

方法2:

 //Using my RemoveDoc() function, I want the button of browse being show out.
 function RemoveDoc(Doc)
 {
xmlhttp1=new XMLHttpRequest();

xmlhttp1.open("GET","functions/remove.php?Doc="+Doc,true);
xmlhttp1.onreadystatechange=function()
{
    if (xmlhttp1.readyState==4 && xmlhttp1.status==200)
    {
            //when i run debugging, it says that the style of null..
    document.getElementById("browse").style.visibility='visible';

    }
}
xmlhttp1.send();

    return false;
    }
    </script>      

どちらも参照ボタンを表示できない2つの方法を試しました。表示されているので、ブラウズオブジェクトに表示されているものを呼び出す必要があります。

4

3 に答える 3

1

http://jsfiddle.net/y3Bad/

いくつかのこと:removeDoc関数内に可視性コードを含め、マークアップではなく JavaScript からハンドラーをバインドする必要があります。また、変数xmlhttp1は暗黙のグローバルです。あなたのremoveDoc関数はパラメータを受け取りますが、Doc何も渡しません。最後に、removeDoc非同期の ajax 呼び出しを行うため、参照ボタンを表示するコード行はすぐには実行されず、ajax 呼び出しが失敗した場合はまったく実行されない可能性があります。

HTML:

<input type="button" id="show" name="show" value="show" />

JS:

​document.getElementById('show').onclick = function () {
    // use display instead of visibility if you don't want the hidden element to take up space

    // setting visibility to empty string will show the element
    document.getElementById('browse').style.visibility = '';
};​
于 2012-07-13T13:12:52.280 に答える
0

私はこれらの2つの関数を使用します:

function hide(objId) {
    document.getElementById(objId).style.display="none";
}

function show(objId) {
    document.getElementById(objId).style.display="";
}
于 2012-07-13T12:42:50.697 に答える
0

たぶん、次のような jQuery を使用してみることができます: http://jsfiddle.net/7fJuu/

于 2012-07-13T13:52:30.300 に答える