2014-01-06 61 views

回答

0

Chek this out

很有效!

HTML:

<input id="button" type="button" value="Klick me"/> 

的Javascript:

document.getElementById("button").onclick = function() { 
    confirm("Great to see you," + " " + prompt("What's Your Name")); 
}; 
+1

谢谢!!!!!!!!!!!它的工作:DDD – EpicGamer757

+0

不要忘记点击chekmark :) –

0
<input name="button1" type="button" value="click me" onclick="clickme()"/> 
<p id="value"></p> 

<script type="javascript"> 

function clickme() 
{ 
    var s = prompt("write a number"); 
    if(s!=null) 
    document.getElementById("value").innerHTML= s; 
} 

</script> 

把提示的值段

0

请通过这个精心

<form name="my_form" id="form_id" method="post" action="my_page_url"> 
    <!-- rest part of your form fields go here --> 
    <!-- this is the submit button --> 
    <input type="submit" name="my_button" value="but_value" onclick="myfunction()"/> 
</form> 

您可以像这样提交此表单。请注意,还有很多其他方法可以做到这一点。

<script type="text/javascript"> 
    function myfunction() 
    { 
     document.getElementById('form_id').submit(); 
    } 
</script> 

请仔细阅读一些教程。有很多这方面的教程。进行谷歌搜索。祝你好运

+1

请不推荐使用在线(突兀)JavaScript事件处理(它确实是不好的做法,使维护难度比它需要)。 –

+0

@DavidThomas:因为我已经证明这个代码,只是通知他,也有在线Java脚本的JS事件处理:)。感谢您的评论 –

相关问题