Notices
Computer & Technology Related Post here for help and discussion of computing and related technology. Internet, TVs, phones, consoles, computers, tablets and any other gadgets.

Web scripting: manipulation of text box data

Thread Tools
 
Search this Thread
 
Old 03 January 2004, 02:53 PM
  #1  
Fatman
Scooby Regular
Thread Starter
 
Fatman's Avatar
 
Join Date: Aug 2002
Posts: 2,390
Likes: 0
Received 0 Likes on 0 Posts
Post

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?
Old 03 January 2004, 09:10 PM
  #2  
SJ_Skyline
Scooby Senior
 
SJ_Skyline's Avatar
 
Join Date: Apr 2002
Location: Limbo
Posts: 21,922
Likes: 0
Received 1 Like on 1 Post
Post

Looks like you are using ASP, on the recieving page:

Code:
strName = Firstname & " " & Surname
Old 03 January 2004, 09:35 PM
  #3  
gareth
Scooby Regular
 
gareth's Avatar
 
Join Date: Jan 1999
Posts: 572
Likes: 0
Received 0 Likes on 0 Posts
Post

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]
Old 03 January 2004, 10:35 PM
  #4  
Fatman
Scooby Regular
Thread Starter
 
Fatman's Avatar
 
Join Date: Aug 2002
Posts: 2,390
Likes: 0
Received 0 Likes on 0 Posts
Post

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
Related Topics
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
south_scoob
ScoobyNet General
22
03 October 2015 01:05 PM
Ganz1983
Subaru
5
02 October 2015 09:22 AM
alcazar
Computer & Technology Related
2
29 September 2015 07:18 PM



Quick Reply: Web scripting: manipulation of text box data



All times are GMT +1. The time now is 04:52 AM.