<html> <head> <title>College Admission Application</title> <style> .form-section { margin-bottom: 20px; } label { font-weight: bold; } input, select { width: 100%; padding: 8px; margin-top: 5px; margin-bottom: 10px; border-radius: 4px; border: 1px solid #ccc; } .submit-btn { background-color: #4CAF50; color: white; padding: 10px 20px; border: none; border-radius: 4px; cursor: pointer; } .submit-btn:hover { background-color: #45a049; } </style> <script> function submitApplication() { var name = document.getElementById('name').value; var email = document.getElementById('email').value; var contact = document.getElementById('contact').value; var school = document.getElementById('school').value; var gpa = document.getElementById('gpa').value; var program = document.getElementById('program').value; var ga = new GlideAjax('CollegeAdmissionProcessor'); ga.addParam('sysparm_name', 'submitApplication'); ga.addParam('name', name); ga.addParam('email', email); ga.addParam('contact', contact); ga.addParam('school', school); ga.addParam('gpa', gpa); ga.addParam('program', program); ga.getXMLAnswer(function(response) { alert('Application submitted successfully: ' + response); }); } </script> </head> <body> <div> <h1>College Admission Application</h1> <!-- Personal Details --> <div class="form-section"> <label for="name">Full Name:</label> <input type="text" id="name" name="name" /> </div> <div class="form-section"> <label for="email">Email:</label> <input type="email" id="email" name="email" /> </div> <div class="form-section"> <label for="contact">Contact Number:</label> <input type="text" id="contact" name="contact" /> </div> <!-- Academic Information --> <div class="form-section"> <label for="school">Previous School/College:</label> <input type="text" id="school" name="school" /> </div> <div class="form-section"> <label for="gpa">GPA:</label> <input type="text" id="gpa" name="gpa" /> </div> <div class="form-section"> <label for="program">Program Selection:</label> <select id="program" name="program" > <option value="">Select a Program</option> <option value="engineering">Engineering</option> <option value="business">Business</option> <option value="arts">Arts</option> </select> </div> <!-- Submit Button --> <div class="form-section"> <button type="submit" class="submit-btn">Submit Application</button> </div> </div> </body> </html>
Script Include
var CollegeAdmissionProcessor = Class.create(); CollegeAdmissionProcessor.prototype = Object.extendsObject(AbstractAjaxProcessor, { submitApplication: function() { var user = new GlideRecord('sys_user'); user.initialize(); user.name = this.getParameter('name'); user.email = this.getParameter('email'); user.phone = this.getParameter('contact'); user.department = this.getParameter('school'); user.u_gpa = this.getParameter('gpa'); // Assuming 'u_gpa' is a custom field in sys_user user.title = this.getParameter('program'); // Assuming the 'program' will be stored in 'title' field user.insert(); return 'Success'; } });
College Application form with HTML and Script Include Code
Working Code Asked question September 18, 2024