标签:style blog http color io os java ar for
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Example:Submit buttons to links</title>
<style type="text/css"></style>
<script type="text/javascript" src="submitToLinks.js"></script>
</head>
<body>
<form action="nogo.php" method="post">
<p>
<label for="Name">Name:</label>
<input type="text" id="Name" name="Name"/>
<input type="submit" value="send"/>
</p>
<p>
<label for="Email">Email:</label>
<input type="text" id="Email" name="Email"/>
<input type="submit" value="check"/>
</p>
</form>
</body>
</html>
submitToLinks.js
function submitToLinks()
{
if(!document.getElementById||!document.createTextNode){return;}
var inputs,i,newLink,newText;
inputs=document.getElementsByTagName(‘input‘);
for(i=0;i<inputs.length;i++)
{
if(inputs[i].getAttribute(‘type‘).toLowerCase()!=‘submit‘)
{continue;i++}
newLink=document.createElement(‘a‘);
newText=document.createTextNode(inputs[i].getAttribute(‘value‘));
newLink.appendChild(newText);
newLink.setAttribute(‘href‘,‘javascript:document.forms[0].submit()‘);
inputs[i].parentNode.replaceChild(newLink,inputs[i]);
//if(i<inputs.length){i--};
}
}
window.onload=submitToLinks;
标签:style blog http color io os java ar for
原文地址:http://www.cnblogs.com/vonk/p/3979517.html