
Apr 22nd, 2008, 15:58
|
 |
Moderator
|
|
Join Date: Mar 2004
Location: Good Ol'London
Age: 22
Posts: 1,617
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
|
Re: help with checkbox and textfield in form
I'm sorry, I edited your post when I meant to copy your code. Bad moderator! bad!
Here's what I think you should have:
- HTML: Select all
<script type="text/javascript">
function showHide(id){
el = document.getElementById(id);
el.style.display = (el.style.display != 'block')? 'block' : 'none';
}
function check(form)
if(document.getElementById('other_check').checked && (document.getElementById('other_textbox').value || '').length <= 0) {
alert('The box labeled "Other" was checked but you didn\'t enter a category into the text box');
else {
form.submit();
}
}
</script>
<form name="change" action="resize.php?action=change" id="change" method="POST">
<p>Your Style: <input type='text' name='style'></p>
<p>Your Bio(less than 300 words):<br><textarea name="bio" cols="70" rows"50"></textarea></p>
<p>What categories would you like to display?<br>
<Input type = 'Checkbox' Name ='web' value= '1'> Websites<br>
<Input type = 'Checkbox' Name ='art' value= '1'> Traditional Artwork<br>
<Input type = 'Checkbox' Name ='ani' value= '1'> Animations<br>
<Input type = 'Checkbox' Name ='vid' value= '1'> Video<br>
<Input type = 'Checkbox' Name ='pho' value= '1'> Photography<br>
<Input type = 'Checkbox' Name ='mus' value= '1'> Music<br>
<input name ='oth' type = 'Checkbox' id="other_check" onClick="showHide('other_text')" value= '1'>
Other<br>
<div id="other_text" style="display:none">If other, please specify:
<input type='text' id="other_textbox" name='other'></div>
<p>
</p>
Choose a background color:<br>
<Input type = 'Radio' Name ='color' value= 'red'> Red<br>
<Input type = 'Radio' Name ='color' value= 'blue'> Blue<br>
<Input type = 'Radio' Name ='color' value= 'green'> Green<br>
<Input type = 'Radio' Name ='color' value= 'black'> Black<br>
<Input type = 'Radio' Name ='color' value= 'grey'> Grey<br>
<Input type = 'Radio' Name ='color' value= 'orange'> Orange<br>
<Input type = 'Radio' Name ='color' value= 'purple'> Purple<br>
<Input type = 'Radio' Name ='color' value= 'yellow'> Yellow<br>
<p><input type='submit' name='Submit' value='Update Page' onClick="try{ check(this.form); }catch(e){}; return false;"></p>
</form>
|