更改表单输入文本名称="" [英] Change Form input text name=""
问题描述
我正在使用
< script type =" text / javascript">
function setAction(frm){
act ='''';
for(x = 0; x< frm.se.length; x ++){
if(frm.se [x ] .checked){
act = frm.se [x] .value;
}
}
if(act ==''MINE''){
frm.action =''MYSEARCHENGINE.HTML'';
}
else if(act ==''OTHER''){
frm.action =''OTHERSEARCHENGINE.HTML'';
}
else {
alert(''请选择一个选项'');
返回false;
}
}
< / script>
用单选按钮更改目标搜索引擎。
这很好,但是.. 。
我还需要更改名称=""选择
单选按钮的< input type = text base。
这两个搜索需要该字段的不同名称。
有人可以帮我这个,或者有一个工作的例子,一个
文本输入字段被提交给选择的搜索引擎。
非常感谢你提前。
德文
dh ***** @ gmail.com écrit:
这很有效,但是......
单选按钮。
这两个搜索需要该字段的不同名称。
< script type =" text / javascript">
function setAction(frm){
act ='''';
for(x = 0; x< frm.se.length; x ++){
if(frm.se [x] .checked){
act = frm.se [x] .value;
}
}
if(act ==''MINE''){
frm.action =''MYSEARCHENGINE.HTML'';
frm [0] .name =''search'';
}
else if(act ==''OTHER''){
frm.action =''OTHERSEARCHENGINE.HTML'';
frm [0] .name = ''找'';
}
else {
alert(''请选择一个选项'');
返回false;
}
返回true;
}
< / script>
< form action ="" onsubmit =" return setAction(this)">
< input type = text value =" your search"的onclick = QUOT; THIS.VALUE =">与
MYSEARCHENGINE:< input type = radio name =" se"值= QUOT; MINE">或者
OTHERSEARCHENGINE:< input type = radio name =" se value =" OTHER">
< input type = submit value =" GO">
< / form>
-
Stephane Moriaux et son [moins] vieux Mac
感谢您的快速回复,但我很害怕没有
清楚。
这是< input type = text name =" THISNAME"我需要根据无线电选择更改
。
要更清楚,这里是所有代码我我正在使用。请参阅
CHANGE_WITH_RADIO_SELECTION以了解我需要通过无线电更改
选择。
再次感谢
Devin
< script type =" text / javascript">
function setAction(frm){
act ='''';
for(x = 0; x< frm.se.length; x ++){
if(frm.se [x] .checked) {
act = frm.se [x] .value;
}
}
if(act = ='''MINE''){
frm.action =''MYSEARCH'';
}
else if( act ==''OTHER''){
frm.action =''OTHERSEARCH'';
}
else {
alert(''请选择一个选项'');
返回false;
}
}
< / script>
< form action ="" onsubmit =" return setAction(this)">
< input type = text value =" Your Search"
name =" CHANGE_WITH_RADIO_SELECTION">
我的搜索
< input type = radio name =" se" value =" MINE">
其他搜索
< input type = radio name =" se" value =" OTHER">
< input type = submit value =" GO">
< / form>
>
I am using
<script type="text/javascript">
function setAction(frm){
act = '''';
for(x=0;x<frm.se.length;x++){
if(frm.se[x].checked){
act = frm.se[x].value;
}
}
if(act == ''MINE''){
frm.action = ''MYSEARCHENGINE.HTML'';
}
else if(act == ''OTHER''){
frm.action = ''OTHERSEARCHENGINE.HTML'';
}
else{
alert(''Please choose an option'');
return false;
}
}
</script>
to change the intended search engine with radio buttons.
That works well, however...
I also need to change the name="" of an <input type=text base on which
radio button is chosen.
The two searches require different names for that field.
Can someone please help me with this, or have a working example of one
text input field being submited to a choice of search engines.
Thank you very much in advance.
Devin
dh*****@gmail.com a écrit :
That works well, however...
I also need to change the name="" of an <input type=text base on which
radio button is chosen.
The two searches require different names for that field.
<script type="text/javascript">
function setAction(frm){
act = '''';
for(x=0;x<frm.se.length;x++){
if(frm.se[x].checked){
act = frm.se[x].value;
}
}
if(act == ''MINE''){
frm.action = ''MYSEARCHENGINE.HTML'';
frm[0].name = ''search'';
}
else if(act == ''OTHER''){
frm.action = ''OTHERSEARCHENGINE.HTML'';
frm[0].name = ''find'';
}
else{
alert(''Please choose an option'');
return false;
}
return true;
}
</script>
<form action="" onsubmit="return setAction(this)">
<input type=text value="Your search" onclick="this.value=''''"> with
MYSEARCHENGINE: <input type=radio name="se" value="MINE"> or
OTHERSEARCHENGINE: <input type=radio name="se" value="OTHER">
<input type=submit value="GO">
</form>
--
Stephane Moriaux et son [moins] vieux Mac
Thank you for your quick response, but I''m afraid I may not have been
clear.
It is the <input type=text name="THISNAME" that I need to change based
on the radio selection.
To Be More Clear, here is all of the code I am using. See
CHANGE_WITH_RADIO_SELECTION to see what I need to change with radio
selection.
Thanks again
Devin
<script type="text/javascript">
function setAction(frm){
act = '''';
for(x=0;x<frm.se.length;x++){
if(frm.se[x].checked){
act = frm.se[x].value;
}
}
if(act == ''MINE''){
frm.action = ''MYSEARCH'';
}
else if(act == ''OTHER''){
frm.action = ''OTHERSEARCH'';
}
else{
alert(''Please choose an option'');
return false;
}
}
</script>
<form action="" onsubmit="return setAction(this)">
<input type=text value="Your Search"
name="CHANGE_WITH_RADIO_SELECTION">
My Search
<input type=radio name="se" value="MINE">
Other Search
<input type=radio name="se" value="OTHER">
<input type=submit value="GO">
</form>
这篇关于更改表单输入文本名称=""的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!