473,395 Members | 1,689 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,395 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 1239
"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 ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.