Overide Textinput settings

Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved

Join Date: Oct 2005
Posts: 240
Reputation: Inny is an unknown quantity at this point 
Solved Threads: 6
Inny's Avatar
Inny Inny is offline Offline
Posting Whiz in Training

Overide Textinput settings

 
0
  #1
Mar 15th, 2008
I want to override the maxlength (chars) seetings below for my board, however I dont have direct access to the templet . Is there a way to script it to increase maxlength?

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <tr>
  2. <td colspan="2" class='pformstrip'>Topic Settings</td>
  3. </tr>
  4. <tr>
  5. <td class='pformleft'>Topic Title</td>
  6. <td class='pformright'><input type='text' size='40' maxlength='50' name='TopicTitle' value='' tabindex='1' class='forminput' /></td>
  7. </tr>
  8. <tr>
  9. <td class='pformleft'>Topic Description</td>
  10. <td class='pformright'><input type='text' size='40' maxlength='40' name='TopicDesc' value='' tabindex='2' class='forminput' /></td>
  11. </tr>
Always carry a flagon of whiskey in case of snakebite and furthermore always carry a small snake.
W. C. Fields
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 55
Reputation: hunkychop is an unknown quantity at this point 
Solved Threads: 4
hunkychop's Avatar
hunkychop hunkychop is offline Offline
Junior Poster in Training

Re: Overide Textinput settings

 
0
  #2
Mar 15th, 2008
what kind of board are you using? can you use javascript in it?
if you can insert javascript on the page, do this...

  1. <script type="text/javascript">
  2. function changeMaxLength()
  3. {
  4. var maxlen = '50';//change this to what maxlength you want
  5. var node=document,classname='forminput';
  6. var a = []; var i;
  7. var re = new RegExp('(^| )'+classname+'( |$)');
  8. var els = node.getElementsByTagName("*");
  9. for(var i=0,j=els.length; i<j; i++)
  10. if(re.test(els[i].className))a.push(els[i]);
  11. for(i=0;a[i]!=undefined;i++){
  12. a[i].setAttribute("maxlength",maxlen);
  13. }
  14. }
  15. changeMaxLength();
  16. </script>
toast
Reply With Quote Quick reply to this message  
Join Date: Oct 2005
Posts: 240
Reputation: Inny is an unknown quantity at this point 
Solved Threads: 6
Inny's Avatar
Inny Inny is offline Offline
Posting Whiz in Training

Re: Overide Textinput settings

 
0
  #3
Mar 15th, 2008
that works great but effects the textarea aka the post typing area, not the title field, can you

change getelementsbytagname to get elements by classname?

<td class='pformright'><input type='text' size='40' maxlength='50' name='TopicTitle' value='' tabindex='1' class='forminput'
Always carry a flagon of whiskey in case of snakebite and furthermore always carry a small snake.
W. C. Fields
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 55
Reputation: hunkychop is an unknown quantity at this point 
Solved Threads: 4
hunkychop's Avatar
hunkychop hunkychop is offline Offline
Junior Poster in Training

Re: Overide Textinput settings

 
0
  #4
Mar 16th, 2008
it already does. check line 5. it should be changing all elements with the class 'forminput'

5. var node=document,classname='forminput';
toast
Reply With Quote Quick reply to this message  
Join Date: Oct 2005
Posts: 240
Reputation: Inny is an unknown quantity at this point 
Solved Threads: 6
Inny's Avatar
Inny Inny is offline Offline
Posting Whiz in Training

Re: Overide Textinput settings

 
0
  #5
Mar 16th, 2008
Not topic title or description. im afraid. *shrugs* Its a very clever peice of code though mate, I appreciate your effort!
Always carry a flagon of whiskey in case of snakebite and furthermore always carry a small snake.
W. C. Fields
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 55
Reputation: hunkychop is an unknown quantity at this point 
Solved Threads: 4
hunkychop's Avatar
hunkychop hunkychop is offline Offline
Junior Poster in Training

Re: Overide Textinput settings

 
0
  #6
Mar 17th, 2008
i don't understand what you mean. i can write it to change the maxlength by name instead of className.
toast
Reply With Quote Quick reply to this message  
Join Date: Oct 2005
Posts: 240
Reputation: Inny is an unknown quantity at this point 
Solved Threads: 6
Inny's Avatar
Inny Inny is offline Offline
Posting Whiz in Training

Re: Overide Textinput settings

 
0
  #7
Mar 18th, 2008
Yes that might work better, Thanks!
Always carry a flagon of whiskey in case of snakebite and furthermore always carry a small snake.
W. C. Fields
Reply With Quote Quick reply to this message  
Join Date: Mar 2007
Posts: 55
Reputation: hunkychop is an unknown quantity at this point 
Solved Threads: 4
hunkychop's Avatar
hunkychop hunkychop is offline Offline
Junior Poster in Training

Re: Overide Textinput settings

 
1
  #8
Mar 19th, 2008
replace the origional with this
  1. <script type="text/javascript">
  2. function changeMaxLength()
  3. { var names=new Array(),name;
  4. names[0] = 'TopicTitle';
  5. // make a new array entry for each input name
  6. names[1] = 'TopicDesc';
  7. for(ib=0;names[ib]!==undefined;ib++){
  8. var maxlen = '50';//change this to what max len you want
  9.  
  10. var node=document,name=names[ib];
  11. var a = []; var i;
  12. var re = new RegExp('(^| )'+name+'( |$)');
  13. var els = node.getElementsByTagName("*");
  14. for(var i=0,j=els.length; i<j; i++)
  15. if(re.test(els[i].getAttribute("name")))a.push(els[i]);
  16. for(i=0;a[i]!=undefined;i++){
  17. a[i].setAttribute("maxlength",maxlen);
  18. }
  19. }
  20. }
  21. changeMaxLength();
  22. </script>
Last edited by hunkychop; Mar 19th, 2008 at 2:58 pm.
toast
Reply With Quote Quick reply to this message  
Join Date: Oct 2005
Posts: 240
Reputation: Inny is an unknown quantity at this point 
Solved Threads: 6
Inny's Avatar
Inny Inny is offline Offline
Posting Whiz in Training

Re: Overide Textinput settings

 
0
  #9
Mar 19th, 2008
Once again, Thanks for you kind efforts Hunky,
Unfortunately That didnt work either. I suspect the problem could be that the coding for maxlength could be written in @ server side aswell?
In anycase Your efforts have taught me some about about javascript and will prove useful in the future, I have saved them away to reference when needed.
I appreciate your taking the time to try to help me like this. Thankyou very much mate, all the best,
cheers Inny
Always carry a flagon of whiskey in case of snakebite and furthermore always carry a small snake.
W. C. Fields
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the JavaScript / DHTML / AJAX Forum
Thread Tools Search this Thread



Tag cloud for JavaScript / DHTML / AJAX
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC