Web scripting: manipulation of text box data
#1
I have three text boxes on a particular page (document is something.aspx). The first is called Firstname, the second is called Surname and the third is called Name. They all reside within a POST Form, and on submission I'd like the Name field to be submitted. The receiving site is expecting Name to be the concatentation of Firstname and Surname. However, I'd like to keep Firstname and Surname separate for my own purposes (i.e. writing individually to dB).
How can I automatically concatenate Firstname and Surname? Can this be scripted?
How can I automatically concatenate Firstname and Surname? Can this be scripted?
#3
Sounds like you want the fields to be already concatenated when the form is submitted to the receiving page?
Add a hidden input element with the name you want to give to the concatenated field, then create a Javascript function with something like
document.form.name = document.form.firstname
+ ' '
+ document.form.surname;
Then, associate the function to either the onClick event of the submit button, or the onSubmit event of the form. Sorry if this is vague or slightly inaccurate, but I hope you get the gist of it!
[Edited by gareth - 1/3/2004 9:38:50 PM]
Add a hidden input element with the name you want to give to the concatenated field, then create a Javascript function with something like
document.form.name = document.form.firstname
+ ' '
+ document.form.surname;
Then, associate the function to either the onClick event of the submit button, or the onSubmit event of the form. Sorry if this is vague or slightly inaccurate, but I hope you get the gist of it!
[Edited by gareth - 1/3/2004 9:38:50 PM]
#4
Thanks lads, but it's sorted. In fact I changed my input boxes to text boxes to expose more methods (yes, it's ASP.NET). The concatenation string was as mentioned; name.Text = firstname.Text & " " & surname.Text where name is the concatenated field which is submitted.
For neatness, I tried rendering the 'name' text box invisible. However, the receiving page then cannot 'see' the field in question. I also tried using a label instead (with the same ID, of 'name') - with the same result. It's a little unsightly having the 'name' field visible (after first name and surname are input) but at least it works!
Cheers
For neatness, I tried rendering the 'name' text box invisible. However, the receiving page then cannot 'see' the field in question. I also tried using a label instead (with the same ID, of 'name') - with the same result. It's a little unsightly having the 'name' field visible (after first name and surname are input) but at least it works!
Cheers
Thread
Thread Starter
Forum
Replies
Last Post
Mattybr5@MB Developments
Full Cars Breaking For Spares
12
18 November 2015 07:03 AM
Sam Witwicky
Engine Management and ECU Remapping
17
13 November 2015 10:49 AM
alcazar
Computer & Technology Related
2
29 September 2015 07:18 PM