gpt4 book ai didi

javascript - html动态生成表单但在发布时不在url中给出日期值

转载 作者:搜寻专家 更新时间:2023-11-01 04:41:58 25 4
gpt4 key购买 nike

function addrow() {

document.getElementById("myTableData").style.display="block";
/*displaying div on click of button abc*/

var el = document.createElement('input');
el.type = 'text';
el.name = 'kname';
/*creating name field*/

var el_r = document.createElement('input');
el_r.type = 'radio';
el_r.name = 'gender';
el_r.value ='FEMALE';
el_r.id = "rad1";
el_r.defaultChecked = true;
/* creating radio button for gender field */

var el_r2 = document.createElement('input');
el_r2.type = 'radio';
el_r2.name = 'gender';
el_r2.value ='MALE';
el_r2.id = "rad2";
/* creating radio button for gender field */

var obj1 = document.createTextNode("Female");
var obj2 = document.createTextNode("Male");

var objLabel = document.createElement("label");
objLabel.htmlFor = el_r.id;
objLabel.appendChild(el_r);
objLabel.appendChild(obj1);

var objLabel2 = document.createElement("label");
objLabel2.htmlFor = el_r2.id;
objLabel2.appendChild(el_r2);
objLabel2.appendChild(obj2);

/* creating drop down for date field */
var el_s = document.createElement('select');
el_s.onchange = function(){
var r = el_s.options[el_s.selectedIndex].value;
alert("selected date"+r); //cheking the selected date value;
}
for(var i=0;i<32;i++)
{
var j = i;
j = document.createElement('option');
j.text=i;
j.name="day";
j.value=j;
el_s.appendChild(j);
}


var month = new Array("January","Februray","March","April","May","June","July","August","September","October","November","December");
var el_sm = document.createElement('select');
for(var i=0;i<month.length;i++)
{
var j = i;
j = document.createElement('option');
j.text=month[i];
j.name="month";
j.value=month[i];
el_sm.appendChild(j);
}

var el_sy = document.createElement('select');
for(var i=2013;i>1950;i--)
{
var j = i;
j = document.createElement('option');
j.text=i;
j.name="year";
j.value=j;
el_sy.appendChild(j);
}



var table = document.getElementById("myTableData");
var tableBody = document.createElement('TBODY');
table.appendChild(tableBody);

var tr = document.createElement('TR');
tableBody.appendChild(tr);

var td = document.createElement('TD');
td.width='175';
td.appendChild(el);
tr.appendChild(td);

var td = document.createElement('TD');
td.width='245';
td.appendChild(objLabel);
td.appendChild(objLabel2);
tr.appendChild(td);

var td = document.createElement('TD');
td.width='245';
td.appendChild(el_s);
td.appendChild(el_sm);
td.appendChild(el_sy);
tr.appendChild(td);

myTableData.appendChild(table);

}
</script>
<input type="submit" value="submit"/>

我在 javascript 的帮助下在 HTML 中动态生成表单,点击名为 abc 的按钮。我的代码工作正常,当我插入值时,但是当我在按钮的帮助下发布此表单时,值名称和性别显示在地址栏中,但 DATE(元素名称“el_s”)选择的值未显示在地址栏。有 2 个按钮,第一个显示显示表单的 div,下一个是表单的提交按钮

最佳答案

您必须设置 el_s.name='date' 以便自动发布数据。

关于javascript - html动态生成表单但在发布时不在url中给出日期值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18651115/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com