I found a lot of example that allow disabling of form elements on checkbox click, but I actually can have a page loaded with a checkbox selected.
I suppose I need some function that will check if the checkbox (let's call it chBox) checked onload and if yes -- disable the fields. If not leave them active. Also I'll need to add onchange statement to my checkbox to enable/disable form elements.
JS is a bit confusing since i'm more familiar with server-side coding...
I whipped up an all-purpose one that evaluates parameter text strings.
Syntax: toggleform('theform','checkbox','textbox1,textbox2')
Javascript functions:
Code:
<script language="javascript">
<!--
function enableob(o) { eval(o+".disabled = false"); }
function disableob(o) { eval(o+".disabled = true"); }
function toggleform(formstr,chkobstr,obstr) {
var checked = eval(formstr+"."+chkobstr+".checked");
var obs = obstr.split(",");
for (i = 0; i < obs.length; i++) {
obs[i] = formstr+"."+obs[i];
}
if (checked == false) {
for (i = 0; i < obs.length; i++) {
disableob(obs[i]);
}
}
else {
for (i = 0; i < obs.length; i++) {
enableob(obs[i]);
}
}
}
-->
</script>
HTML:
Code:
<noscript><p>You do not have scripting enabled and cannot use the below form because of it.</p></noscript>
<form name="myform">
<p>To accept the license terms for posting, click the checkbox below:<br>
<input type="checkbox" name="mycheck" onclick="toggleform('document.myform','mycheck','pname,ptext')"> I Accept</p>
<b>Name:</b> <input type="textbox" value="your nickname" name="pname" disabled="true"><br>
<b>Post:</b><br>
<textarea name="ptext" disabled="true">Your post here</textarea>
No problem at all. I started to learn web design like 2-3 years back, and I am only 16 years old... god damn I think its funny when people have trouble with it, but maybe that comes from my programming experience... Anything else?
savvykms, I like your script. Mind if I post it over at JavaScript Source? I'll give you the proper credit, of course. I just need the name and URL you want to use.
I have made many like it, very nice control scripts etc. I think my only problem is keeping up with broswer compatibility. Luckily I now use Firefox as well. You know what Macintosh users? f*ck you all! Same with anyone who uses Netscape or Safari!
Now that that is over, if anyone on this forum wishes to use my scripts, feel free, credit or no credit (I would perfer credit). Please add in a email link if you give credit to savvykms[a]aim[d]com. Maybe use this:
/*Credit goes to Savvy (email: savvykms[a]aim[d]com) for this script. Do not email to this address asking for help. You may use this script freely, but include this notice if you do.*/
Some examples of things I have made:
* 3-4 TicTacToe games (AI or player vs player)
* connect four
* 5 or more attempts at text-based games (press the attack button, have items, attacks, health, cheats etc)
* 2-3 fancy calculators
* 2 or more customize web broswer attempts
* 2 or more search engines
* customized email links (fills in subject body etc with values from a simple anchor or button)
* remote control windows
* popup spammers (hehe, just for fun, crashes computers)
* text editors (HTML Applications (HTA))
* Quake2 Gloom control maker (HTA, uses filesystem to save config files)
* more
non-javascript
PHP: forums, games, online chat scripts, dynamic images, search engine (was called Web Savvy and looks similar to Google and works same basic way, was only published for a short while)
Bookmarks