Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Creating 3 part telephone input

Participant ,
Jan 19, 2010 Jan 19, 2010

Hi. Does anyone have an idea on the best way to change a variable called "NPHONE" into a 3 part telephone input instead of one input?

My problem is this is on a very very large site and is used in so many places that changing the database to fields such as "nphone1", "nphone2", "nphone3" is not feasible.

I am wondering if there is a way to take change what is already there into something like this:

<input type="text" maxlength="3" name="nphone1"> - <input type="text" maxlength="3" name="nphone2"> - <input type="text" maxlength="4" name="nphone1">

Then possibly set the existing form field name of "NHPONE" to equal the 3 form fields above?

I think this code below is setting another variable called "NPHN1" to equal what the original "NPHONE" variable was.

<cfset structinsert(arguments.formData,'NPHN1',arguments.formData.NPHONE)>

Would there be a way to swap out the above line of code to set "NPHN1" to equal my 3 new phone fields?


Thanks in advance for your time.

481
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Participant , Jan 19, 2010 Jan 19, 2010

It's possible to break your phone string into a comma delimited list and save into that same db field so somethng  like 800,555,5555 instad of 800-555-5555. This way you can loop through the list when displaying.  Also if you use form to save this data u can use same form field name for all 3 and it will automaticaly pass it in comma delimited format.

for the form you would do

<input type="text" maxlength="3" name="nphone"> - <input type="text" maxlength="3" name="nphone"> - <input type="text" max

...
Translate
LEGEND ,
Jan 19, 2010 Jan 19, 2010

I'd concatonate them on the action page myself.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jan 19, 2010 Jan 19, 2010

It's possible to break your phone string into a comma delimited list and save into that same db field so somethng  like 800,555,5555 instad of 800-555-5555. This way you can loop through the list when displaying.  Also if you use form to save this data u can use same form field name for all 3 and it will automaticaly pass it in comma delimited format.

for the form you would do

<input type="text" maxlength="3" name="nphone"> - <input type="text" maxlength="3" name="nphone"> - <input type="text" maxlength="4" name="nphone">

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jan 19, 2010 Jan 19, 2010
LATEST

Thanks. I didn't realize that you could split up input like that with the same field name.  That should solve my problem!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources