473,233 Members | 1,551 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,233 software developers and data experts.

HTML Form question

On my form I have a text input box.
There are also radio buttons.

I need to take the value of the input box and the value of the selected
radio button and concatenate them with a plus sign in between.

So if the input box's value is: "Hello"
and the input box's name is name=step1
and the radio button's value is: "David"

I want the output to be:

step1=Hello+David

with the plus sign between them.

How can I do this?

Thanks!
Jul 23 '05 #1
1 1236
"vbMark" <no@email.com> wrote in message
news:Xn************************@130.133.1.4...
On my form I have a text input box.
There are also radio buttons.

I need to take the value of the input box and the value of the selected radio button and concatenate them with a plus sign in between.

So if the input box's value is: "Hello"
and the input box's name is name=step1
and the radio button's value is: "David"

I want the output to be:

step1=Hello+David

with the plus sign between them.

How can I do this?


<form name="myForm">
<input type="text" name="myInput" value="Text"><br>
<input type="radio" name="myRadio" value="One"> 1<br>
<input type="radio" name="myRadio" value="Two"> 2<br>
<input type="radio" name="myRadio" value="Three"> 3<br>
<input type="button" value="Append input and radio"
onclick="
alert(
myFunction(
this.form.elements['myInput'],
this.form.elements['myRadio']
)
);">
</form>
<script type="text/javascript">
function myFunction(textInput, radioInput) {
var s = textInput.value;

if ('undefined' == typeof radioInput.length) {
// normalize the collection of radio buttons
// into an array if there is only one
radioInput = [ radioInput ];
}

var ii = radioInput.length;
while (ii-- > 0) {
if (radioInput[ii].checked) {
return s + '+' + radioInput[ii].value;
}
}
return s;
}
</script>

(inline JavaScript split across multiple lines for readability and to
avoid wordwrap)

--
Grant Wagner <gw*****@agricoreunited.com>
comp.lang.javascript FAQ - http://jibbering.com/faq
Jul 23 '05 #2

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

Similar topics

1
by: sumithradevi | last post by:
Hello Friends, I have two forms(form1 and form2) on my html page. question1 : can i access form 1 variables in form 2?. if so how? question 2: when form2 action is saveci.jsp . can i access...
2
by: Mark Watkins | last post by:
Of course, this is not an html board, but some of you may be able to answer this question. Copy and past the html below into a text file so you can open it in IE and see what I mean: ...
4
by: VK | last post by:
09/30/03 Phil Powell posted his "Radio buttons do not appear checked" question. This question led to a long discussion about the naming rules applying to variables, objects, methods and properties...
5
by: Richard Cornford | last post by:
I am interested in hearing opinions on the semantic meaning of FORM (elements) in HTML. I have to start of apologising because this question arose in a context that is not applicable to the...
22
by: Luke | last post by:
Elements with name attribute: form, input, textarea, a, frame, iframe, button, select, map, meta, applet, object, param, img (if you know more reply...) Methods of addresing html elements:...
16
by: Philippe C. Martin | last post by:
Hi, I am trying to change the data in a form field from python. The following code does not crash but has no effect as if "form" is just a copy of the original html form. Must I recreate the...
2
by: Hazzard | last post by:
I just realized that the code I inherited is using all asp.net server controls (ie. webform controls) and when I try to update textboxes on the client side, I lose the new value of the textbox when...
11
by: VB Programmer | last post by:
Is there a limit as to how big an aspx page's html can be? (number of characters) Why do I ask? I have a webform with a lot of ActiveX controls (shows up as OBJECT in html). When I place like...
4
by: Chris | last post by:
Hello. I had a question that I was hoping someone might be able to answer. I have an ASP .NET Web Form with a custom control that generates HTML based on certain criteria. This control is...
1
by: eunever32 | last post by:
Hi I have a struts (1.1) form <html:form <html:text <html:text ...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

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.