Created
May 21, 2020 15:02
-
-
Save salsalabs/727c3ebe97a65ec65f2149e01c4c6574 to your computer and use it in GitHub Desktop.
Demonstration script for moving the first name in a donation page before the last name.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
// Script to move the last name before the first name on a donation page. | |
// Only run this script on donation pages. This should work for both | |
// regular pages and pages with a Salsa shortcut. | |
if (window.location.href.indexOf('/salsa/donation/') != -1) { | |
// Wait for the page to be loaded. | |
$(document).ready(function() { | |
// Find the first name. Return if it's not there. | |
fn = $('input[name="First_Name"]'); | |
if (fn.length == 0) { | |
return; | |
} | |
//Find the last name. Return if it's not there. | |
ln = $('input[name="Last_Name"]'); | |
if (ln.length == 0) { | |
return; | |
} | |
// The fields are both wrapped in <div> tags. That makes the <div> | |
// tags the "parents" for the fields. Move the <div> tag for last | |
// name before the <div> tag for fist name. | |
ln.parent().insertBefore(fn.parent()) | |
}); | |
</script> | |
<!-- SalsaStaff 377344: END move last name before first name in donation pages. --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment