|
|
|
| Web Hosting |
![]() ![]() |
Problem With Selecting A Textbox Content |
Jul 12 2007, 11:28 AM
Post
#1
|
|
|
Super Member Group: [HOSTED] Posts: 818 Joined: 8-April 06 From: Lima - Peru Member No.: 12,579 myCENTs:3.57 |
What i want to do is to first enabled a disabled text box, and then focus and select all the contents of this text box after the user clicks on a checkbox, i have it working with simple HTML and Javascript but how can i do to get the similar result using the DOM??? For simplicity i only include this code that works:
CODE <html> <head> <script type="text/javascript"> function toggle(formname,checkname) { var c="CantField"; if(checkname.checked==true) { checkname.value="on"; document.f[c].disabled=false; document.f[c].focus(); document.f[c].select(); } else { checkname.value="off"; document.f[c].value="0"; document.f[c].disabled=true; } return; } function init() { document.f.CantField.disabled = true; } // using DOM function initD() { document.getElementById('CantField').setAttribute("disabled",true); } function toggleD(formname,checkname) { var c="CantField"; if(checkname.checked==true) { document.getElementById(checkname).setAttribute("value","on"); document.getElementById(c).setAttribute("disabled",false); document.getElementById(c).focus(); document.getElementById(c).select(); } else { document.getElementById(checkname).setAttribute("value","off"); document.getElementById(c).setAttribute("disabled","true"); document.getElementById(c).setAttribute("value","0"); } } </script> </head> <body onload="init()"> <form name="f" action="page.php" method="post" > <input type="checkbox" value="off" name="CheckField" id="CheckField" onclick="toggle('f',this)" /> <input type="text" name="CantField" id="CantField" value="0" /> <input type="submit" value="Check Out" name="submitCar" /> <input type="button" value="Cancel" name="cancelCar" onclick="java script:this.form.reset();"> </form> </body> </html> I know that this code must be optimizied but it is only for simplicity because it is a very heavy form. When I use the toggleD() function the select method dont work, why happens this??? Am I doing something wrong??? Best regards, EDIT: Well, i can't find a solution to the DOM problem so i decide to not use it basically because the select() doesn't work in any manner, if someone get the solution please post it. This post has been edited by TavoxPeru: Jul 17 2007, 11:51 PM |
|
|
|
![]() ![]() |
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:
Similar Topics
| Topic Title | Replies | Topic Starter | Views | Last Action | |||
|---|---|---|---|---|---|---|---|
![]() |
3 | geektech | 1,551 | Yesterday, 10:28 PM Last post by: iG-Paul |
|||
![]() |
6 | jess704 | 133 | 2nd January 2009 - 11:17 AM Last post by: sakmac |
|||
![]() |
11 | Feelay | 614 | 31st December 2008 - 09:45 AM Last post by: mastercomputers |
|||
![]() |
4 | jlhaslip | 919 | 30th December 2008 - 08:50 PM Last post by: iG- |
|||
![]() |
14 | ikenalleenik | 2,275 | 30th December 2008 - 01:22 PM Last post by: iG-saumyadeep |
|||
![]() |
21 | tamuna90 | 1,620 | 29th December 2008 - 06:55 PM Last post by: iG-Mick |
|||
![]() |
5 | Vicious_AD | 893 | 29th December 2008 - 09:51 AM Last post by: iG-abdullah |
|||
![]() |
8 | laniczech | 224 | 5th December 2008 - 10:24 AM Last post by: wutske |
|||
![]() |
7 | Logan Deathbringer | 1,342 | 5th December 2008 - 02:01 AM Last post by: xboxrulz |
|||
![]() |
6 | irwan6179 | 1,449 | 1st December 2008 - 07:58 PM Last post by: iG-patrik |
|||
![]() |
14 | victorhu | 3,396 | 30th November 2008 - 06:48 AM Last post by: iG-Roger |
|||
![]() |
11 | hoplite | 1,714 | 26th November 2008 - 12:34 PM Last post by: iG-pandawarne |
|||
![]() |
9 | nightfox | 1,726 | 25th November 2008 - 02:21 AM Last post by: iG-cover |
|||
![]() |
3 | TavoxPeru | 152 | 24th November 2008 - 03:20 PM Last post by: Quatrux |
|||
![]() |
20 | Grafitti | 2,197 | 15th November 2008 - 11:28 AM Last post by: Guest |
|||
|
Lo-Fi Version | Time is now: 8th January 2009 - 05:03 AM |
© 2009 AstaHost: Free Web Hosting & Technical Discussion, Free Web Hosting. a member of xisto.
Powered by Invision Board. Skin: IPB Forum Skins
Expand / Collapse Navigation



Jul 12 2007, 11:28 AM





