[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 271
  • Last Modified:

Update form value

I have the field ATAccName, when the user leaves this blank I want to populate it with the value from fields ATConFName and ATConLName. I have seen this done before. Any help you can provide is appreciated. I have to do this with several fields but if you can help me with this one I can do the others.

Thank you in advance.
<form id="ATForm" onsubmit="return Validate(this)" action="https://www.autotask.net/autotask/AutoFormHandlers/ServiceController.aspx" method="post">
    <table cellspacing="0" cellpadding="0" width="500">
        <tbody>
            <tr>
                <td>Company (If not a company, use first and last name)<span style="color: red"><font size="2"> *</font></span></td>
                <td><input id="ATAccName" style="width: 250px" type="text" maxlength="200" name="ATAccName" /> </td>
            </tr>
            <tr>
                <td>First Name<span style="color: red"><font size="2"> *</font></span></td>
                <td><input id="ATConFName" style="width: 250px" type="text" maxlength="40" name="ATConFName" /> </td>
            </tr>
            <tr>
                <td>Last Name<span style="color: red"><font size="2"> *</font></span></td>
                <td><input id="ATConLName" style="width: 250px" type="text" maxlength="40" name="ATConLName" /> </td>
            </tr>
            <tr>
                <td>Phone #<span style="color: red"><font size="2"> *</font></span></td>
                <td><input id="ATAccPhone" style="width: 250px" type="text" maxlength="50" name="ATAccPhone" /> </td>
            </tr>
            <tr>
                <td>Address<span style="color: red"><font size="2"> *</font></span></td>
                <td><input id="ATConAddr1" style="width: 250px" type="text" maxlength="128" name="ATConAddr1" /> </td>
            </tr>
            <tr>
                <td>Suite / Apt #<span></span></td>
                <td><input id="ATConAddr2" style="width: 250px" type="text" maxlength="128" name="ATConAddr2" /> </td>
            </tr>
            <tr>
                <td>City<span style="color: red"><font size="2"> *</font></span></td>
                <td><input id="ATConCity" style="width: 250px" type="text" maxlength="32" name="ATConCity" /> </td>
            </tr>
            <tr>
                <td>State<span style="color: red"><font size="2"> *</font></span></td>
                <td><select id="ATConState" size="1" name="ATConState" unselectable="off">
                <option selected="true">Select One</option>
                <option value="NA">Non Applicable</option>
                <option value="AL">Alabama</option>
                <option value="AK">Alaska</option>
                <option value="AB">Alberta</option>
                <option value="AS">American Samoa</option>
                <option value="AZ">Arizona</option>
                <option value="AR">Arkansas</option>
                <option value="BC">British Columbia</option>
                <option value="CA">California</option>
                <option value="CO">Colorado</option>
                <option value="CT">Connecticut</option>
                <option value="DE">Delaware</option>
                <option value="DC">District of Columbia</option>
                <option value="FL">Florida</option>
                <option value="GA">Georgia</option>
                <option value="HI">Hawaii</option>
                <option value="ID">Idaho</option>
                <option value="IL">Illinois</option>
                <option value="IN">Indiana</option>
                <option value="IA">Iowa</option>
                <option value="KS">Kansas</option>
                <option value="KY">Kentucky</option>
                <option value="LA">Louisiana</option>
                <option value="ME">Maine</option>
                <option value="MB">Manitoba</option>
                <option value="MD">Maryland</option>
                <option value="MA">Massachusetts</option>
                <option value="MI">Michigan</option>
                <option value="MN">Minnesota</option>
                <option value="MS">Mississippi</option>
                <option value="MO">Missouri</option>
                <option value="MT">Montana</option>
                <option value="NE">Nebraska</option>
                <option value="NV">Nevada</option>
                <option value="NB">New Brunswick</option>
                <option value="NH">New Hampshire</option>
                <option value="NJ">New Jersey</option>
                <option value="NM">New Mexico</option>
                <option value="NY">New York</option>
                <option value="NF">Newfoundland</option>
                <option value="NC">North Carolina</option>
                <option value="ND">North Dakota</option>
                <option value="MP">Northern Mariana Island</option>
                <option value="NT">Northwest Territories</option>
                <option value="NS">Nova Scotia</option>
                <option value="OH">Ohio</option>
                <option value="OK">Oklahoma</option>
                <option value="ON">Ontario</option>
                <option value="OR">Oregon</option>
                <option value="OT">Outside North America</option>
                <option value="PW">Palau</option>
                <option value="PA">Pennsylvania</option>
                <option value="PE">Prince Edward Island</option>
                <option value="PQ">Quebec</option>
                <option value="RI">Rhode Island</option>
                <option value="SK">Saskatchewan</option>
                <option value="SC">South Carolina</option>
                <option value="SD">South Dakota</option>
                <option value="TN">Tennessee</option>
                <option value="TX">Texas</option>
                <option value="UT">Utah</option>
                <option value="VT">Vermont</option>
                <option value="VA">Virginia</option>
                <option value="WA">Washington</option>
                <option value="WV">West Virginia</option>
                <option value="WI">Wisconsin</option>
                <option value="WY">Wyoming</option>
                <option value="YT">Yukon Territory</option>
                </select> </td>
            </tr>
            <tr>
                <td>Zip Code<span style="color: red"><font size="2"> *</font></span></td>
                <td><input id="ATConZip" style="width: 250px" type="text" maxlength="16" name="ATConZip" /> </td>
            </tr>
            <tr>
                <td>Note Description<span style="color: red"><font size="2"> *</font></span></td>
                <td><input id="ATNotDetail" style="width: 250px" type="text" maxlength="1000" name="ATNotDetail" /> </td>
            </tr>
            <tr>
                <td><br />
                </td>
            </tr>
            <tr>
                <td><input id="btnSubmit" type="submit" value="Submit" /> </td>
            </tr>
        </tbody>
    </table>
</form>

Open in new window

0
jimseiwert
Asked:
jimseiwert
1 Solution
 
BarsMonsterCommented:
Not sure what is you server-side language, but you can check value on the server side, and concatenate ATConFName and ATConLName if it's empty.

Also, you may do this on onSUbmit javascript form event handler .
0
 
jimseiwertAuthor Commented:
this form is doing a postback. How would I do the onsubmit javascript with out interfering on the postback?
0
 
jimseiwertAuthor Commented:
everything is being done with html
0
 
erikTsomikSystem Architect, CF programmer Commented:
try something like this
function check () {
      if (document.getElementById('ATAccName').value ==0) {
            var z  = document.getElementById('ATAccName').value;
            var x  = document.getElementById('ATConFName').value;
            var y  = document.getElementById('ATConLName').value;
      document.getElementById('ATAccName').value = X+y
            }
      
      }
0
 
quincydudeCommented:
in your Validate(myform) function add

myform.ATAccName.value = myform.ATConFName.value + " " +  myform.ATConLName.value;

just simple as that:)
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now