AbigailH Posted July 27 Share Posted July 27 Hi, I'm working on a client site and would like to remove the Last Name field from a Newsletter block on the Home page. I added the following code to the Code Injection Footer and it appears to work but when I go back into Edit mode the Last Name field reappears. Any ideas what I'm doing wrong here? Thank you! <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> <script> const lnames = document.querySelectorAll('.last-name input') const lnameFields = document.querySelectorAll('.last-name') $(document).ready(function(){ lnames.forEach(lname => { lname.value = "-" }) lnameFields.forEach(lnameField => { lnameField.style.display = "none" }) Link to comment
tuanphan Posted July 28 Share Posted July 28 Hi, You missing a closing </script> tag at the end of code Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message How to: Setup Password & Share url - Insert Custom CSS - Page Header - Upload Custom Font - Upload File - Find Block ID - Contact Customer Care Link to comment
AbigailH Posted July 28 Author Share Posted July 28 @tuanphan Thank you for the reply! I guess I didn't copy/paste the entire code in my post, I did have the closing </script> tag at the end. Sorry about that. I tried removing it and starting over but the code still isn't working. Does the rest of the code look correct to you? It's strange because it looks like it removes the Last Name field when I'm still the Code injection page but when I go into Edit mode the field comes back. Any ideas? Link to comment
tuanphan Posted July 29 Share Posted July 29 Try this new code. If it doesn't work, please share site url, we can check easier <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.0/jquery.min.js"></script> <script> $(document).ready(function(){ lastName = document.querySelector('.last-name input'); lastName.value = "NA"; hideLastName = document.querySelector('.last-name'); hideLastName.style.display = "none"; }); </script> Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message How to: Setup Password & Share url - Insert Custom CSS - Page Header - Upload Custom Font - Upload File - Find Block ID - Contact Customer Care Link to comment
AbigailH Posted July 29 Author Share Posted July 29 @tuanphan Thank you again! The new code seemed to do the trick when I test the website with a password, but in Edit mode the Last Name field still appears. Seems strange to me but as long as it's working on the live site I'm happy. Thank you so much for your help with this. Link to comment
Solution tuanphan Posted July 30 Solution Share Posted July 30 23 hours ago, AbigailH said: @tuanphan Thank you again! The new code seemed to do the trick when I test the website with a password, but in Edit mode the Last Name field still appears. Seems strange to me but as long as it's working on the live site I'm happy. Thank you so much for your help with this. If the code doesn't work in edit mode, will need to access your site backend to check this. If you can add me as a contributor, I can check easier Email me if you have need any help (free, of course.). Answer within 24 hours. Or send to forum message How to: Setup Password & Share url - Insert Custom CSS - Page Header - Upload Custom Font - Upload File - Find Block ID - Contact Customer Care Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment