BuildMyWeb Posted September 18, 2015 Share Posted September 18, 2015 javascript: function highlight_field( field_name ) { alert(field_name); document.getElementsByName(field_name)[0].style.backgroundColor = 'yellow'; } HTML form: <form action='http://buildmyweb.org/testing/mfs/scripts/handler_register.php' method='post'> <input class='req' type='text' placeholder='First Name' name="reg_f_name" /> <input class='req' type='text' placeholder='Last Name' name="reg_l_name" /> ... <input type='submit' name='submit_button' value='Register' id='reg_submit' /> </form> when i load the page in question, the ALERT(); is triggering and displaying the correct value, 'reg_f_name'. yet the background color of that field is not changing. what am i doing wrong? Quote Link to comment https://forums.phpfreaks.com/topic/298217-backgroundcolor-not-working/ Share on other sites More sharing options...
Solution scootstah Posted September 18, 2015 Solution Share Posted September 18, 2015 Where are you calling highlight_field()? 1 Quote Link to comment https://forums.phpfreaks.com/topic/298217-backgroundcolor-not-working/#findComment-1521123 Share on other sites More sharing options...
BuildMyWeb Posted September 18, 2015 Author Share Posted September 18, 2015 dzuh! thank you scoot i was calling it prior to the form. i suck with js. Quote Link to comment https://forums.phpfreaks.com/topic/298217-backgroundcolor-not-working/#findComment-1521124 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.