473,394 Members | 1,697 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

disabled input fields-help please!!

35
hi everyone,
i have a long list of checkboxes and textfields
and when a checkbox is cleared i want the textfield to become disabled and when its checked enabled, that's easy i know.
but the question is if it is disabled would it be submitted with the form?
and the other thing is i want to link each checkbox somehow to a textfield, so
i can enter their values in 2 related database fields, but im having trouble submitting the data while keeping related items together and identifiable through each other.
Now i thought of using a hidden field and each time a checkbox is checked , i would
add the pair to the field's value and remove it when cleared, but that seems a real hard pain in the ass task.

if you have any ideas that can help me out i'd be thankful :confused:
Jul 27 '06 #1
3 8394
iam_clint
1,208 Expert 1GB
1. Disabled input field should submit
2. As to keeping related text boxes with check boxes you may look into arrays for form inputs.
3. Database column a = checkbox column b = text field input that would keep them linked.
Jul 28 '06 #2
iam_clint
1,208 Expert 1GB
Expand|Select|Wrap|Line Numbers
  1. <script>
  2. function swap() {
  3.  for (var i=0,n=document.test.check.length;i<n;i++)  {
  4.         checked = document.test.check[i].checked;
  5.     if (checked==false) {
  6.         document.test.textfield[i].disabled = true;
  7.     } else {
  8.         document.test.textfield[i].disabled = false;
  9.     }
  10.   }
  11. }
  12. </script>
  13. <body onload="swap();">
  14. <form name="test">
  15. <input type="checkbox" id="check" onclick="swap();">Click Me!<input type="text" id="textfield"><br>
  16. <input type="checkbox" id="check" onclick="swap();">Click Me!<input type="text" id="textfield"><br>
  17. <input type="checkbox" id="check" onclick="swap();">Click Me!<input type="text" id="textfield"><br>
  18. <input type="checkbox" id="check" onclick="swap();">Click Me!<input type="text" id="textfield"><br>
  19. <input type="checkbox" id="check" onclick="swap();">Click Me!<input type="text" id="textfield"><br>
  20. <input type="checkbox" id="check" onclick="swap();">Click Me!<input type="text" id="textfield"><br>
  21. <input type="checkbox" id="check" onclick="swap();">Click Me!<input type="text" id="textfield"><br>
  22. <input type="checkbox" id="check" onclick="swap();">Click Me!<input type="text" id="textfield"><br>
  23. <input type="checkbox" id="check" onclick="swap();">Click Me!<input type="text" id="textfield"><br>
  24. <input type="checkbox" id="check" onclick="swap();">Click Me!<input type="text" id="textfield"><br>
  25. <input type="checkbox" id="check" onclick="swap();">Click Me!<input type="text" id="textfield"><br>
  26. <input type="checkbox" id="check" onclick="swap();">Click Me!<input type="text" id="textfield"><br>
  27. <input type="checkbox" id="check" onclick="swap();">Click Me!<input type="text" id="textfield"><br>
  28. </form>
  29.  

This is a sample code i made up for you.. it is an array of all the check boxes and input fields... the corresponding text field has the same array # as the check box.
this will enable and disable the text field based on the check box. as to the database you will have todo a similar method in your submit page to loop through the array and put the two togethor and insert them into the dabase how ever you want.
Jul 28 '06 #3
r_o
35
thanks man
i tried the code not exactly what i want
i think this shit is givin me a headache so
i'll try to find another way to deal with it
10x anyway
Jul 30 '06 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Matt | last post by:
what's the differences between readonly and disabled attribute?? When I do the post, it couldn't get both values <%= fname %>. any ideas?? <input type="text" name="fname" value="Joe" readOnly>...
10
by: Ice Man | last post by:
hello all, i was wondering if i could enable/disable input according to the user, e.g. enable input2 if input1 is enable, else it's disabled. Also, if input1 is deleted then input2 is disabled....
5
by: Alon Zilkha | last post by:
Hi All, I just noticed a problem with Internet Explorer on Service Pack 2 of Windows XP and it is driving me insane!! I would greatly appreciate it if someone could help me out... I have a...
5
by: bart plessers | last post by:
Hello, Somewhere in my code I have <input TYPE="button" NAME="btnFirst" VALUE="<<" OnClick="GetFile('1')" DISABLED> I changed the layout of the INPUT with a stylesheet to INPUT { color:...
3
by: Marc Jennings | last post by:
I have an architectural question that I would appreciate some input on, please. Earlier this year I spent some time in Sri Lanka working with a rpoject to help after the tsunami. A part of the...
3
by: Tariq Ahmad | last post by:
hi, i have a textbox into which i insert a value using javascript and then disable (again using javascript). when i post the page back to itself and look at the .Text property of the textbox...
1
by: ndawg123 | last post by:
Hey guys what im trying to do is write a yatzee game with C. And im stuck already and its the start?!?! I want the user to type there 5 numbers. i.e My program so far does this Please...
1
by: mikaint | last post by:
I've read that if a field is set to disabled, it will be excluded from the submited fields when sending a form. Is there an alternative way to disable a field but still, send it with the form? I...
1
by: moveitho | last post by:
Hi, I have the following script on my site but need to implement a select menu into the script as it would make it a lot tidier. This script adds the required amount of fields selected by the...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.