hadoob024 Posted April 14, 2010 Share Posted April 14, 2010 Is the hiding/showing of text fields done differently than for buttons? I ask because I have the following text field: <input type="text" name="case_id_c" class="sqsEnabled" tabindex="0" id="case_id_c" size="" value="" > And if I call the following javascript, this field disappears: document.getElementById('case_id_c').style.display = 'none'; However, I have the following button: <input type="button" name="btn_clr_case_id_c" tabindex="0" title="Clear [Alt+C]" accessKey="C" class="button" onclick="this.form.case_id_c.value = ''; value="Clear"> And if I run the following code, nothing happens: document.getElementsByName("btn_clr_case_id_c").style.display = 'none'; Not sure what's going on. Any thoughts??? Quote Link to comment https://forums.phpfreaks.com/topic/198527-manipulating-text-field-versus-a-button/ Share on other sites More sharing options...
JustLikeIcarus Posted April 14, 2010 Share Posted April 14, 2010 What about if you give the button an id attribute and call getElementById? Quote Link to comment https://forums.phpfreaks.com/topic/198527-manipulating-text-field-versus-a-button/#findComment-1041747 Share on other sites More sharing options...
hadoob024 Posted April 14, 2010 Author Share Posted April 14, 2010 That's what I wanted to do, but we're using that SugarCRM platform, so these are buttons generated by it, and I haven't figured out how (or even if I can) to add an ID attribute to the button. Quote Link to comment https://forums.phpfreaks.com/topic/198527-manipulating-text-field-versus-a-button/#findComment-1041779 Share on other sites More sharing options...
JustLikeIcarus Posted April 14, 2010 Share Posted April 14, 2010 I was looking through the Sugar source and found the file include/Smarty/plugins/function.sugar_button.php which appears to build the buttons and the ID attribute is not being used. Maybe you can edit this. Quote Link to comment https://forums.phpfreaks.com/topic/198527-manipulating-text-field-versus-a-button/#findComment-1041800 Share on other sites More sharing options...
hadoob024 Posted April 14, 2010 Author Share Posted April 14, 2010 Thanks. Yeah, I spoke with my manager about this. The problem with updating that file is that it's a core Sugar file, so when we upgrade Sugar, these changes will be overwritten. He wants me to come up with an upgrade-safe solution, which I understand but which also makes it so that I'm not done with this yet Quote Link to comment https://forums.phpfreaks.com/topic/198527-manipulating-text-field-versus-a-button/#findComment-1041809 Share on other sites More sharing options...
JustLikeIcarus Posted April 14, 2010 Share Posted April 14, 2010 Ok getElementsByName() is returning an array of objects so to hide that button you would want to do var btn = document.getElementsByName("btn_clr_case_id_c"); btn[0].style.display = 'none'; Quote Link to comment https://forums.phpfreaks.com/topic/198527-manipulating-text-field-versus-a-button/#findComment-1041825 Share on other sites More sharing options...
hadoob024 Posted April 14, 2010 Author Share Posted April 14, 2010 THANK YOU!!! That was it! I think I was missing the fact that an array was being returned. It works beautifully now!!! Thanks again! Quote Link to comment https://forums.phpfreaks.com/topic/198527-manipulating-text-field-versus-a-button/#findComment-1041841 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.