Support Browser:Chrome (目前只用這個測過)
<script type="text/javascript">
function makeForm(){
// - create the form element and it's attributes
var f=document.createElement('form');
f.setAttribute('name','myForm');
f.setAttribute('action','createElement_test.html');
f.setAttribute('target','_blank');
f.setAttribute('method','get');
var formText=document.createTextNode('Enter your name: ');
// - next, create a text input where you'll enter your name
var yourName=document.createElement('input');
yourName.setAttribute('type','text');
yourName.setAttribute('name','NAME');
yourName.setAttribute('value','');
// - create a submit input to submit the form
var b=document.createElement('input');
b.setAttribute('type','submit');
b.setAttribute('value','click to test this form');
// - finally, append the text node, the text input, and the submit input to the form
f.appendChild(formText);
// - put a line break between the text node and the inputs
f.appendChild(document.createElement('br'));
f.appendChild(yourName);
f.appendChild(b);
document.getElementById('formTest').appendChild(f);
}
</script>
ref: Here
==================================================
function add_radioBlock(whichID)
{
var elementID = document.getElementById('LeftBlock-2');
var infoPanel = document.getElementById('LeftBlock-2');
infoPanel.innerHTML = '';
var radio, form1, but_submit;
var argv='';
var map=2; //dynimages
form1 = document.createElement('form');
form1.setAttribute('method', 'post');
form1.setAttribute('action', 'Shilin_district.jsp');
for(var i = 0; i < Taiwan_county[whichID].length; i++)
{
argv="CountyImage('RightBlock'," + map + ", 0)"; //可以把變數用字串組合好後
radio = document.createElement('input');
radio.setAttribute('type', 'radio');
radio.setAttribute('name', 'chooseOnecounty');
radio.setAttribute('value', i+4);
radio.setAttribute('id', i+4);
radio.setAttribute('onMouseover', argv); //再丟進去,(這樣就可以丟function了)
form1.appendChild(radio);
form1.innerHTML += Taiwan_county[whichID][i] + '<br>';
}
but_submit = document.createElement('input');
but_submit.setAttribute('type', 'submit');
but_submit.setAttribute('value', 'submit');
form1.appendChild(but_submit);
document.getElementById('LeftBlock-2').appendChild(form1);
}
沒有留言:
張貼留言