473,698 Members | 2,344 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Change Form input text name=""

I am using

<script type="text/javascript">
function setAction(frm){
act = '';
for(x=0;x<frm.s e.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 = 'OTHERSEARCHENG INE.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

May 11 '06 #1
13 8621
ASM
dh*****@gmail.c om 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.s e.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 = 'OTHERSEARCHENG INE.HTML';
frm[0].name = 'find';
}
else{
alert('Please choose an option');
return false;
}
return true;
}
</script>

<form action="" onsubmit="retur n setAction(this) ">
<input type=text value="Your search" onclick="this.v alue=''"> with
MYSEARCHENGINE: <input type=radio name="se" value="MINE"> or
OTHERSEARCHENGI NE: <input type=radio name="se" value="OTHER">
<input type=submit value="GO">
</form>
--
Stephane Moriaux et son [moins] vieux Mac
May 11 '06 #2
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.

May 11 '06 #3
To Be More Clear, here is all of the code I am using. See
CHANGE_WITH_RAD IO_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.s e.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="retur n setAction(this) ">
<input type=text value="Your Search"
name="CHANGE_WI TH_RADIO_SELECT ION">
My Search
<input type=radio name="se" value="MINE">
Other Search
<input type=radio name="se" value="OTHER">
<input type=submit value="GO">
</form>

May 11 '06 #4
ASM
dh*****@gmail.c om a écrit :
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.


its name have no importance.
function catches this element by its index in the form frm collection

in previous example
<input type=text name="THISNAME"
has to be the first element after opening tag 'form'

<form action="" onsubmit="retur n setAction(this) ">
<input type=text name="THISNAME" value="Your search"
onclick="this.v alue=''"> with
MYSEARCHENGINE: <input type=radio name="se" value="MINE"> or
OTHERSEARCHENGI NE: <input type=radio name="se" value="OTHER">
<input type=submit value="GO">
</form>

--
Stephane Moriaux et son [moins] vieux Mac
May 11 '06 #5
ASM
dh*****@gmail.c om a écrit :
To Be More Clear, here is all of the code I am using. See
CHANGE_WITH_RAD IO_SELECTION to see what I need to change with radio
selection.


what are new names ?
here, in this example,
they'll be 'search' for mine and 'find' for other

<script type="text/javascript">
function setAction(frm){
act = '';
for(x=0;x<frm.s e.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 = 'OTHERSEARCHENG INE.HTML';
frm[0].name = 'find';
}
else{
alert('Please choose an option');
return false;
}
return true;
}
</script>
<form action="" onsubmit="retur n setAction(this) ">
<input type=text value="Your Search"
name="CHANGE_WI TH_RADIO_SELECT ION">
My Search
<input type=radio name="se" value="MINE">
Other Search
<input type=radio name="se" value="OTHER">
<input type=submit value="GO">
</form>
Tested in Fx
--
Stephane Moriaux et son [moins] vieux Mac
May 11 '06 #6
dh*****@gmail.c om said the following on 5/11/2006 11:27 AM:
To Be More Clear, here is all of the code I am using. See
CHANGE_WITH_RAD IO_SELECTION to see what I need to change with radio
selection.


document.forms['formID'].elements['oldNameHere'].name = "newNameHer e";

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
May 11 '06 #7
I'm very sorry. I do not want to change the Form Name, I want to change
the

<input type=text name="THIS"

The two searches that I am using require this text field to have
different names.

May 11 '06 #8
I Got it now, thank you. I missed the part where you said the text name
should be first after tag.

Thank you very much

May 11 '06 #9
dh*****@gmail.c om said the following on 5/11/2006 11:49 AM:
I'm very sorry. I do not want to change the Form Name, I want to change
the

<input type=text name="THIS"

The two searches that I am using require this text field to have
different names.


Answer: They typically post without quoting.

I would give you the question but I would have to quote it first.

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Question: How can you spot 90% of Google posters?
May 11 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2437
by: aa | last post by:
I am traing to output the following HTML string from PHP: "<td><input name='".$i-2."' size='2' type='text' onBlur='myfunction(".$i-2.")'></td>" But it somehow mistreats $i-2. PHP does not throw any errors but the browser renders the table incorrectly. I got round this by introducing another variable j=i-2 and using it in place of i-2 It works. However I am interested to understand why is does not work with i-1. Any comments?
2
17758
by: John Davis | last post by:
I want to know what's the differences between Request.Form("Field Name") and Request.QueryString("Field Name") OR they function exactly the same, which is to return the value of the field?? Thanks, John
4
3961
by: Marc Elser | last post by:
Hi Everybody, Can someone please tell me how to access the form name if there's a form field named "name", for example: <form name="myform"> <input type="text" name="name" value="Marc"> <input type="button" onClick="alert(this.form.name);"> </form>
3
2700
by: Pavils Jurjans | last post by:
Hello, I have bumped upon this problem: I do some client-side form processing with JavaScript, and for this I loop over all the forms in the document. In order to identify them, I read their "name" property (which sources from "name" HTML attribue). The problem is, that if the form contains form control named "name", it overwrites the form name property. In fact, I'm quite surprised that it's so easy to spoil any of the form object...
5
2283
by: Werner Partner | last post by:
On my testpage http://www.sonoptikon.de/test.php I have this <table><tr> <td valign="top" align="center" style="width:150px;"> <form action=test.php method="get">
3
4168
by: aryayudhi | last post by:
I have a html page that has javascript that works perfectly in IE, but not in Firefox. The use of this javascript to change "Tab" to "Enter" Button. When we press Tab, it is like when we press Enter button. How to make this script can be run on Firefox? I would be grateful to anybody who can help me on this, as I have got out of my depth with this problem. Thanks, Arya ======== This is the script : <script language="javascript"...
2
2263
by: alxasa | last post by:
Hello, I am hoping someone can help me with this. I need a javascript function, which sits inside a <input type="text" name="firstname"> line of code. Now, if someone starts typing fine, but when it goes 1 character past 15 characters (15 characters only allowed), in this case I would like the contents of the input to be cleared out (automatically), and reset the input and its value back to nothing. a) Can this be done, and will someone...
4
1651
by: Apple1 | last post by:
Hello! I would like to switch elements on the fly. Dynamicly turn "A" elenent an "input" tag. This is what I tried: <html> <head> <script>
1
1799
by: chas2007 | last post by:
I need to pass a variable from a php function to a form. Does anyone have an example of code that would do this? Below is the code. I need to pass the "return value" from the php function mem_cost to the "amount" listed in the "form" <?php function mem_cost() { $w_month = strftime("%m"); if (($w_month >= "01") && ($w_month <= "06"))
0
8680
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8871
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7738
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6528
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5861
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4371
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.