dennismonsewicz Posted December 29, 2008 Share Posted December 29, 2008 I have a script that reads the length of a string coming out of a database and based on the length is how long the input field is to edit that particular field. But the problem i am having is its not accurately sizing the input field correctly $testimonialLength = strlen($row->testimonial); Any ideas? The input is like this: <input class="inputbox" type="text" name="testimonial" id="testimonial" size="<?php echo $testimonialLength; ?>" value="<?php echo $row->testimonial; ?>" /> Quote Link to comment Share on other sites More sharing options...
flyhoney Posted December 29, 2008 Share Posted December 29, 2008 Elaborate on "its not accurately sizing the input field correctly". Quote Link to comment Share on other sites More sharing options...
dennismonsewicz Posted December 29, 2008 Author Share Posted December 29, 2008 the whole string is not showing up in the input field... like it cuts off the string.. you have to place your cursor in the field and then scroll over to see the rest of the string.. make sense? Quote Link to comment Share on other sites More sharing options...
flyhoney Posted December 29, 2008 Share Posted December 29, 2008 Yeah. You might want to use CSS if you want to more accurately control the width of the text box. <input class="inputbox" type="text" name="testimonial" id="testimonial" style=width: "<?php echo $testimonialLength * 12; ?>px" value="<?php echo $row->testimonial; ?>" /> Quote Link to comment Share on other sites More sharing options...
dennismonsewicz Posted December 29, 2008 Author Share Posted December 29, 2008 gotcha yeah the way i am getting around it is like this: $testimonialLength = strlen($row->testimonial) + 30; Thanks for the help! Quote Link to comment Share on other sites More sharing options...
flyhoney Posted December 29, 2008 Share Posted December 29, 2008 Here is an interesting discussion: http://stackoverflow.com/questions/285421/style-html-text-input-size-to-match-its-contents Quote Link to comment 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.