| | |
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; 16 Days Ago at 10:40 am.
0
#2 16 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.
All opinions count.
0
#3 16 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.
0
#4 15 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.
All opinions count.
![]() |
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 |
advanced alerts apache api archive array autosuggest beginner binary broken cakephp checkbox class clients cms code cron curl database date datepart display dynamic echo email emptydisplayvalue eregi error execute explodefunction file files folder form forms function functions google hack head href htaccess html if...loop image include insert ip javasciptvalidation javascript joomla keywords library limit link login mail matching menu mlm multiple mysql number object oop password paypal pdf php phpincludeissue query radio random recursive remote script search searchbox server sessions shot smarty source space speed sql syntax system table tutorial update upload url validator variable vbulletin video web website youtube





