我在访问我的表单时遇到了问题.当我使用document.form [0] .mylink.value时,它识别值并输出到我指定的innerHTML.但是,当我使用document.myform.mylink.value时,它似乎无法识别表单.我在chrome 6.0和firefox 3.6.3中都尝试了这个,并且在两者中都得到了相同的结果.我真的需要能够通过使用表单名称(而不是document.form [0])来访问我的表单值,任何想法为什么document.myform.mylink.value不起作用?
<form name="myform">
<table>
<tr><td valign="middle" align="center">
<div id="textResponse"></div>
</td></tr>
<tr><td height="30" valign="middle" align="center">
<input name="mylink" value="Enter a URL" size="31" />
</td></tr>
<tr><td valign="top" align="center">
<a href="javascript:submitForm2();">Click</a>
</td></tr>
</table>
</form>
<script type="text/javascript">
function submitForm2(){
//This one does NOT work:
my_link = document.myform.mylink.value;
//This one also does NOT work:
//my_link = document.forms['myform'].mylink.value;
//This one works:
//my_link = document.forms[0].mylink.value;
document.getElementById("textResponse").innerHTML="<p>"+my_link+"</p>";
}
</script>
Run Code Online (Sandbox Code Playgroud) 我有一个简单的模态对话框,我在自己的linux服务器上开发,运行php 5.3.脚本(如下所示)在我的服务器上运行正常.但是,我将它移动到我的客户端的linux服务器,而不是回显它显然应该做的文本/ html,它从>(大于)字符回显所有实际的PHP代码.有谁知道为什么它会回应实际代码?有没有导致这个的php.ini设置?或两个设置中的文件编码差异?
<?php
$to_email = 'myname@myemail.com';
$link = $_GET['link'];
if(!$link){
echo '<p>Have a suggestion?<br />Enter the URL below!</p>';
}else if(strlen($link) > 256 || !preg_match('/^(http:\/\/)?subdomain\.somesite\.com\/(somedir\/)?anotherdir\/(.+)/',$link) && !preg_match('/^(http:\/\/)?somedomain2\.com\/somedir2\/(.+)/',$link)){
echo '<p class="error">Whoops, the URL entered doesn\'t <br />match the criteria.</p>';
}else{
$link = str_replace("\n.", "\n..", $link);
if(!preg_match('/^http:\/\//',$link)){
$link = 'http://'.$link;
}
mail($to_email, 'New URL Suggestion', "A new URL has been suggested from your site:\n\n".$link,"From: ".$to_email."\r\n");
echo '<p>Thank you for submitting this URL! <br />It should be live within 24 hours.</p>';
}
?> …Run Code Online (Sandbox Code Playgroud)