Results 1 to 6 of 6

Thread: Combining fields in a Form

  1. #1
    Join Date
    Jan 2006
    Posts
    170
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Default Combining fields in a Form

    Does anyone know how to combine form fields? I have 3 separate fields for a phone number (areacode, prefix, and number). I'd like to pass a single, formatted field to the CGI script [(areacode) prefix-number]. Is that possible?

    Thanks.

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Not reliably so, no. Why would you want to do such a thing?
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Jan 2006
    Posts
    170
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Default

    Because, as I said, I've separated the phone number into three input fields but I only want a single formated field sent to the CGI script.

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Ah - you have no control over the CGI script, I take it.
    Well, try:
    Code:
    <form onsubmit="
      var a = elements['area'],
        p = elements['prefix'],
        n = elements['number'];
      elements['phone'].value = a + " " + p + "-" + n;
      return true;
    ">
    ... where "phone" is a hidden input element.

    However, as I said, this is very unreliable; if you can possibly alter the CGI script to take the three seperate fields, I strongly suggest you do so.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #5
    Join Date
    Jan 2006
    Posts
    170
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Default

    Twey.

    Thanks, I'll try it. No, I don't have any control over the CGI. Based on what you said about its reliability though, I may end up just making it a single Phonenumber field and let the submitter enter the number however they want. Not as neat, but a lot easier to implement.

    Thanks again.

  6. #6
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    True. Neatness counts for something, but efficiency and user-control is nicer, in my opinion.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •