| | |
radio button validation
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
we have two radio buttons with same name. when we check radiobutton no.of imagefile boxes appear.
for example i have two radio buttons. if i check 1 radio button appear 5 image upload fields. now selects another radio button selects then appear only 10 image upload field. anybody help.
for example i have two radio buttons. if i check 1 radio button appear 5 image upload fields. now selects another radio button selects then appear only 10 image upload field. anybody help.
Last edited by muralikalpana; 29 Days Ago at 10:40 am.
-1
#2 29 Days Ago
AM I correct in assuming you have:
2 radiobuttons - one to display 5 file upload fields and one to display 10 upload fields.
A quick and dirty solution would be to hide/show through javascript and css:
This gives an array of file elements (0 - 9).
In your head area:
If you fill file widgets in range 5-9 and then hide the last 5, they will still try to upload the files - so you could write something a bit "cleverer" to deal with this. This is just an example - I wouldn't use this in a production site.
2 radiobuttons - one to display 5 file upload fields and one to display 10 upload fields.
A quick and dirty solution would be to hide/show through javascript and css:
PHP Syntax (Toggle Plain Text)
<input name="showups" type="radio" value="0" onclick="show_up(5);return false;" selected="selected" /><label for="show5">Show 5 upload fields</label> <input name="showups" id="show10" type="radio" value="1" onclick="show_up(10);return false;" /><label for="show10">Show 10 upload fields</label> <input type="file" name="upload[]" /> <input type="file" name="upload[]" /> <input type="file" name="upload[]" /> <input type="file" name="upload[]" /> <input type="file" name="upload[]" /> <div id = "extras" class="show"> <input type="file" name="upload[]" /> <input type="file" name="upload[]" /> <input type="file" name="upload[]" /> <input type="file" name="upload[]" /> <input type="file" name="upload[]" /> </div>
This gives an array of file elements (0 - 9).
In your head area:
PHP Syntax (Toggle Plain Text)
<script> function show_up(x){ if(x > 5){ document.getElementById('extras').className = 'show'; }else{ document.getElementById('extras').className = 'hide'; } } </script> <style> .hide{ display:none; } </style>
If you fill file widgets in range 5-9 and then hide the last 5, they will still try to upload the files - so you could write something a bit "cleverer" to deal with this. This is just an example - I wouldn't use this in a production site.
"...the woods would be a very silent place if no birds sang except for the best"
All opinions count - unless you're a serial downvoter.
F'enw i yw Mr. Blaidd. Byddwch yn ofalus - dwi'n cnoi.
All opinions count - unless you're a serial downvoter.
F'enw i yw Mr. Blaidd. Byddwch yn ofalus - dwi'n cnoi.
0
#3 29 Days Ago
•
•
•
•
AM I correct in assuming you have:
2 radiobuttons - one to display 5 file upload fields and one to display 10 upload fields.
A quick and dirty solution would be to hide/show through javascript and css:
PHP Syntax (Toggle Plain Text)
<input name="showups" type="radio" value="0" onclick="show_up(5);return false;" selected="selected" /><label for="show5">Show 5 upload fields</label> <input name="showups" id="show10" type="radio" value="1" onclick="show_up(10);return false;" /><label for="show10">Show 10 upload fields</label> <input type="file" name="upload[]" /> <input type="file" name="upload[]" /> <input type="file" name="upload[]" /> <input type="file" name="upload[]" /> <input type="file" name="upload[]" /> <div id = "extras" class="show"> <input type="file" name="upload[]" /> <input type="file" name="upload[]" /> <input type="file" name="upload[]" /> <input type="file" name="upload[]" /> <input type="file" name="upload[]" /> </div>
This gives an array of file elements (0 - 9).
In your head area:
PHP Syntax (Toggle Plain Text)
<script> function show_up(x){ if(x > 5){ document.getElementById('extras').className = 'show'; }else{ document.getElementById('extras').className = 'hide'; } } </script> <style> .hide{ display:none; } </style>
If you fill file widgets in range 5-9 and then hide the last 5, they will still try to upload the files - so you could write something a bit "cleverer" to deal with this. This is just an example - I wouldn't use this in a production site.
PHP Syntax (Toggle Plain Text)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <script> function show_up(x){ if(x > 5){ document.getElementById('extra').style.display = 'table-cell'; document.getElementById('extras').style.display = 'none'; }else{ document.getElementById('extras').style.display = 'table-cell'; document.getElementById('extra').style.display = 'none'; } } </script> <style> .hide{ display:none; } </style> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <form name="form" method="post"> <input name="showups" type="radio" value="0" onclick="show_up(5);return false;"/><label for="show5">Show 5 upload fields</label> <input name="showups" id="show10" type="radio" value="1" onclick="show_up(10);return false;"/><label for="show10">Show 10 upload fields</label> <div id = "extra" class="show" style="display:none"> <input type="file" name="upload[]" /> <input type="file" name="upload[]" /> <input type="file" name="upload[]" /> <input type="file" name="upload[]" /> <input type="file" name="upload[]" /> <input type="file" name="upload[]" /> <input type="file" name="upload[]" /> <input type="file" name="upload[]" /> <input type="file" name="upload[]" /> <input type="file" name="upload[]" /> </div> <div id = "extras" class="show" style="display:none"> <input type="file" name="upload[]" /> <input type="file" name="upload[]" /> <input type="file" name="upload[]" /> <input type="file" name="upload[]" /> <input type="file" name="upload[]" /> </div> </form> </body> </html>
•
•
•
•
see once its working. but radio button checking problem. what is the solution for this.
-1
#4 28 Days Ago
Change this line to hide the extras by default:
Also you need a selected="selected" attribute inside the first radiobutton to ensure that the first one (5 file) is 'on'.
PHP Syntax (Toggle Plain Text)
<div id = "extras" class="hide">
"...the woods would be a very silent place if no birds sang except for the best"
All opinions count - unless you're a serial downvoter.
F'enw i yw Mr. Blaidd. Byddwch yn ofalus - dwi'n cnoi.
All opinions count - unless you're a serial downvoter.
F'enw i yw Mr. Blaidd. Byddwch yn ofalus - dwi'n cnoi.
![]() |
Similar Threads
- How to insert a value from radio button in mysql (PHP)
- Map, Radio Button, and Coordinates (Java)
- radio button looses the selected state after validation (JavaScript / DHTML / AJAX)
- radio button validation problem (JavaScript / DHTML / AJAX)
- radio button validation (JavaScript / DHTML / AJAX)
- problem with my radio button validation js (JavaScript / DHTML / AJAX)
Other Threads in the PHP Forum
- Previous Thread: My OOP based login -- Help me start
- Next Thread: Plugin could not be activated because it triggered a fatal error.
| Thread Tools | Search this Thread |
ajax apache api array back basic beginner binary broken cakephp checkbox class cms code computing cron curl customizableitems database date delete display dynamic echo email error file files filter folder form forms forum function functions gc_maxlifetime google headmethod host href htaccess html image include insert integration ip java javascript joomla limit link login loop mail malfunction memmory memory menu mlm multiple mysql navigation oop parsing paypal pdf php problem query radio random recursion regex remote script search server sessions sms snippet soap source space sql syntax system table thesishelp trouble tutorial update upload url validator variable video web xml youtube






