We help IT Professionals succeed at work.

Update form value

jimseiwert asked
Medium Priority
Last Modified: 2013-11-19
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">
                <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>
                <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>
                <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>
                <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>
                <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>
                <td>Suite / Apt #<span></span></td>
                <td><input id="ATConAddr2" style="width: 250px" type="text" maxlength="128" name="ATConAddr2" /> </td>
                <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>
                <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>
                <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>
                <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>
                <td><br />
                <td><input id="btnSubmit" type="submit" value="Submit" /> </td>

Open in new window

Watch Question

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 .


this form is doing a postback. How would I do the onsubmit javascript with out interfering on the postback?


everything is being done with html
erikTsomikSystem Architect, CF programmer

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
in your Validate(myform) function add

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

just simple as that:)

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.