Jump to content

alanl1

Members
  • Posts

    80
  • Joined

  • Last visited

Everything posted by alanl1

  1. i tried putting that in but it just shows errors
  2. yes, so can they be looped through or is it impossible thanks
  3. thanks adam got it now
  4. I have a function as shown below that makes dropdown boxes appear and disappear based on a checkbox being ticked or unticked. Is there a way to loop through these as there could be 2 dropdowns or maybe even 50. I have tried the for loop within the function but it does not seem to like it! any ideas??? function show_hide( isChecked ) { alert(isChecked) ; //Can i loop through the dropdowns rather than hardcode them all as the number is unknow per spreadsheet. // This for loop does not work... foreach ($_POST['secondDD'] as $boxIndex=>$boxValue) { alert(document.getElementById('secondDD[$boxIndex]').value) ; } document.getElementById('secondDD[1]').style.display = ( isChecked ? 'block' : 'none' ); document.getElementById('secondDD[1]').disabled = !isChecked; document.getElementById('secondDD[2]').style.display = ( isChecked ? 'block' : 'none' ); document.getElementById('secondDD[2]').disabled = !isChecked; }
  5. how do i actually assign a value to it for js to see
  6. thanks that works
  7. ok ive done that <?php $newfilename = $_POST['filename']; echo " the filename is ".$newfilename; ?> and it still shows nothing, I can see it in the browser http://localhost/test.php?filename=Synergy_SARnew.csv
  8. fantastic thankyou
  9. wow that was fast. i have tried that which sort of works, it shows in the browser ok now I still cannot seem to echo this out on the next page though, am i doing something else wrong $newfilename = $_POST[$filename]; echo " the filename is ".$newfilename;
  10. I have a form <form method='POST' name="myform" action="test.php?filename=$filename" > when I try to retrieve the variable I get nothing. My browser just shows this http://localhost/test.php?filename=$filename $newfilename = $_POST[$filename]; echo " the filename is ".$newfilename; the filename is
  11. I have a lot of dropdown boxes that I am echoing out as shown below is there a way to echo out as many as the previous page contains as they are created dynamically from spreadsheets so there could be one dropdown box or many dropdown boxes <?php $secondDropbox0 = $_POST['secondDD0']; $secondDropbox1 = $_POST['secondDD1']; $secondDropbox2 = $_POST['secondDD2']; $secondDropbox3 = $_POST['secondDD3']; $secondDropbox4 = $_POST['secondDD4']; $thirdDropbox0 = $_POST['thirdDD0']; $initialDropbox0 = $_POST['dropdown0']; echo "the inital dropdown box value is equal to " . $initialDropbox0; ?><br><?php echo "the seconds first dropdown box value is equal to " . $secondDropbox0; ?><br><?php echo "the seconds second dropdown box value is equal to " . $secondDropbox1; ?><br><?php echo "the seconds third dropdown box value is equal to " . $secondDropbox2; ?><br><?php echo "the seconds fourth dropdown box value is equal to " . $secondDropbox3; ?><br><?php echo "the seconds fifth dropdown box value is equal to " . $secondDropbox4; ?><br><?php echo "the thirds 1st dropdown box value is equal to " . $thirdDropbox0; ?>
  12. t
  13. I have a function which is supoosed to show and hide dropown boxes when I tick and untick a checkbox but it is not working function show_hide( isChecked ) { document.getElementById('secondDD1').style.display = ( isChecked ? 'block' : 'none' ); document.getElementById('secondDD1').disabled = !isChecked; document.getElementById('thirdDD2').style = ( isChecked ? 'block' : 'none' ); document.getElementById('thirdDD1').disabled = !isChecked; } <select name="<?php echo "thirdDD" .$c?>" onchange="fillSelect(this,categories[this.value],'<?php echo "thirdDD" .$counter2++ ?>')"><?php echo "<option selected>Please Choose</option>"; echo "<option value='DeviceID3'>DeviceID</option>"; echo "<option value='Product3'>Product</option>"; ?></select> <td> <input type=checkbox id=cbox name=cbox value=unselected onclick=show_hide(this.checked);>One to many</td> is there a way to echo out the document element values EG alert(document.getElementById('thirdDD1')) ;
  14. yeah it is lol, im new to this so still in the learning stages
  15. and the html as requested <!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>linefeeds1</title> </head> <body> <script type="text/javascript"> var categories = []; categories["startList"] = ["DeviceID","Manufacturer","Product","Version","NULL","Ignore"] categories["Manufacturer"] = ["DeviceID","Product","Version","NULL","Ignore"]; categories["DeviceID"] = ["Manufacturer","Product","Version","NULL","Ignore"]; categories["Product"] = ["DeviceID","Manufacturer","Version","NULL","Ignore"]; categories["Version"] = ["DeviceID","Manufacturer","Product","NULL","Ignore"]; categories["NULL"] = ["DeviceID","Manufacturer","Product","Version","NULL","Ignore"]; categories["Ignore"] = ["DeviceID","Manufacturer","Product","Version","NULL","Ignore"]; categories["startList2"] = ["DeviceID","Manufacturer","Product","Version","NULL","Ignore"] categories["Manufacturer2"] = ["DeviceID","Product","Version","NULL","Ignore"]; categories["DeviceID2"] = ["Manufacturer","Product","Version","NULL","Ignore"]; categories["Product2"] = ["DeviceID","Manufacturer","Version","NULL","Ignore"]; categories["Version2"] = ["DeviceID","Manufacturer","Product","NULL","Ignore"]; categories["NULL2"] = ["DeviceID","Manufacturer","Product","Version","NULL","Ignore"]; categories["Ignore2"] = ["DeviceID","Manufacturer","Product","Version","NULL","Ignore"]; categories["startList3"] = ["DeviceID","Manufacturer","Product","Version","NULL","Ignore"] categories["Manufacturer3"] = ["DeviceID","Product","Version","NULL","Ignore"]; categories["DeviceID3"] = ["Manufacturer","Product","Version","NULL","Ignore"]; categories["Product3"] = ["DeviceID","Manufacturer","Version","NULL","Ignore"]; categories["Version3"] = ["DeviceID","Manufacturer","Product","NULL","Ignore"]; categories["NULL3"] = ["DeviceID","Manufacturer","Product","Version","NULL","Ignore"]; categories["Ignore3"] = ["DeviceID","Manufacturer","Product","Version","NULL","Ignore"]; function show_hide( isChecked ) { alert("checkbox has been selected") ; document.getElementById('secondDD1').style.display = ( isChecked ? 'block' : 'none' ); document.getElementById('secondDD1').disabled = !isChecked; } function fillSelect(sel,ary,nxt){ if (ary&&sel.form){ var frm=sel.form,nme=sel.name.replace(/\d/g,""),i=Number(sel.name.replace(/\D/g,""))+1,nxt=frm[nxt],z0=0; while (frm[nme+i]){ frm[nme+i].length = 1; frm[nme+i].selectedIndex=0; i++; } for (;z0<ary.length;z0++){ nxt.options[z0+1]=new Option(ary[z0],ary[z0]); } nxt.selectedIndex=0; } } function getValue(isValue) { alert(isValue); } function init() { fillSelect(document.forms[0]['dropdown0'],categories['startList'],'dropdown0') fillSelect(document.forms[0]['secondDD0'],categories['startList2'],'secondDD0') fillSelect(document.forms[0]['thirdDD0'],categories['startList3'],'thirdDD0') } navigator.appName == "Microsoft Internet Explorer" ? attachEvent('onload', init, false) : addEventListener('load', init, false); function myfunction() { alert("Please ensure the file is in csv format"); } </script> <style type="text/css"> .specialImage{ position:fixed; bottom:0; right:0; z-index:100; /* or higher/lower depending on other elements */ } </style> <table width="100%" border="0"> <tr> <td width="33%"> </td> <td width="33%"><img src="images/Data3.jpg" width="389" height="100" alt="Data33" align="middle"></td> <td width="33%"> </td> </tr> </table> <style type="text/css"> .specialImage{ position:fixed; bottom:0; right:0; z-index:100; /* or higher/lower depending on other elements */ } </style> <img src="images/MCP.jpg" class="specialImage" width="120" height="90" alt="Microsoft Certified Partner"> <form method='POST' name="myform" action="test.php" > <table width=100% border=0><tr width=100% align=center><td colspan=4>&nbsp</td></tr><tr width=100% align=center><td colspan=4 style=white-space:nowrap;width:100%;></td></tr><tr width=100% align=center><td colspan=4>Here we need info to assist user</td></tr><tr width=100%><td width=25%>&nbsp</td> <td width=20%>&nbsp</td> <td width=15%> </td> <td width=40%> </td></tr><tr width=100%><td width=25% align=right>&nbsp</td> <td colspan=3>By selecting one to many selection box will allow to split and cleanse the desired column into a maximum of 3 from the dropdown boxes</td></tr><tr width=100%><td width=25% align=right>&nbsp</td> <td colspan=3>By not selecting one to many will only allow for first set of dropdown boxes to cleanse data</td></tr><tr width=100%><td width=25% align=right>&nbsp</td> <td colspan=3>&nbsp</td></tr><tr width=100%><td width=25% align=right>&nbsp</td> <td width=20%> <input type=checkbox id=cbox name=cbox value=unselected onclick=show_hide(this.checked);>One to many</td> <td width=15%> </td> <td width=40%> </td></tr><tr width=100%><td width=25%> </td> <td width=20%>&nbsp</td> <td width=15%> </td> <td width=40%> </td></tr></table><table width=100% border=0><tr width=25% align=right><td><input type='text' id='Software Man' value='Software Man' DISABLED='disabled' style='background-color:White; color:Black;'></td><td width=20% align=left> <---- Matches to -----> <select name="dropdown0" onchange="fillSelect(this,categories[this.value],'dropdown1')"><option selected>Please Choose</option><option value='DeviceID'>DeviceID</option><option value='Product'>Product</option><option value='Manufacturer'>Manufacturer</option><option value='Version'>Version</option><option value='NULL'>NULL</option><option value='Ignore'>Ignore</option></select></td><td width=15% align=left> <select name="secondDD0" style="display: none;" onchange="fillSelect(this,categories[this.value],'secondDD1')"><option selected>Please Choose</option><option value='DeviceID2'>DeviceID</option><option value='Product2'>Product</option><option value='Manufacturer2'>Manufacturer</option><option value='Version2'>Version</option><option value='NULL2'>NULL</option><option value='Ignore2'>Ignore</option></select></td><td width=40% align=left> <select name="thirdDD0" style="display: none;" onchange="fillSelect(this,categories[this.value],'thirdDD1')"><option selected>Please Choose</option><option value='DeviceID3'>DeviceID</option><option value='Product3'>Product</option><option value='Manufacturer3'>Manufacturer</option><option value='Version3'>Version</option><option value='NULL3'>NULL</option><option value='Ignore3'>Ignore</option></select></td></tr></table><table width=100% border=0><tr width=25% align=right><td><input type='text' id='Part Number' value='Part Number' DISABLED='disabled' style='background-color:White; color:Black;'></td><td width=20% align=left> <---- Matches to -----> <select name="dropdown1" onchange="fillSelect(this,categories[this.value],'dropdown2')"><option selected>Please Choose</option><option value='DeviceID'>DeviceID</option><option value='Product'>Product</option><option value='Manufacturer'>Manufacturer</option><option value='Version'>Version</option><option value='NULL'>NULL</option><option value='Ignore'>Ignore</option></select></td><td width=15% align=left> <select name="secondDD1" style="display: none;" onchange="fillSelect(this,categories[this.value],'secondDD2')"><option selected>Please Choose</option><option value='DeviceID2'>DeviceID</option><option value='Product2'>Product</option><option value='Manufacturer2'>Manufacturer</option><option value='Version2'>Version</option><option value='NULL2'>NULL</option><option value='Ignore2'>Ignore</option></select></td><td width=40% align=left> <select name="thirdDD1" style="display: none;" onchange="fillSelect(this,categories[this.value],'thirdDD2')"><option selected>Please Choose</option><option value='DeviceID3'>DeviceID</option><option value='Product3'>Product</option><option value='Manufacturer3'>Manufacturer</option><option value='Version3'>Version</option><option value='NULL3'>NULL</option><option value='Ignore3'>Ignore</option></select></td></tr></table><table width=100% border=0><tr width=25% align=right><td><input type='text' id='Product Name' value='Product Name' DISABLED='disabled' style='background-color:White; color:Black;'></td><td width=20% align=left> <---- Matches to -----> <select name="dropdown2" onchange="fillSelect(this,categories[this.value],'dropdown3')"><option selected>Please Choose</option><option value='DeviceID'>DeviceID</option><option value='Product'>Product</option><option value='Manufacturer'>Manufacturer</option><option value='Version'>Version</option><option value='NULL'>NULL</option><option value='Ignore'>Ignore</option></select></td><td width=15% align=left> <select name="secondDD2" style="display: none;" onchange="fillSelect(this,categories[this.value],'secondDD3')"><option selected>Please Choose</option><option value='DeviceID2'>DeviceID</option><option value='Product2'>Product</option><option value='Manufacturer2'>Manufacturer</option><option value='Version2'>Version</option><option value='NULL2'>NULL</option><option value='Ignore2'>Ignore</option></select></td><td width=40% align=left> <select name="thirdDD2" style="display: none;" onchange="fillSelect(this,categories[this.value],'thirdDD3')"><option selected>Please Choose</option><option value='DeviceID3'>DeviceID</option><option value='Product3'>Product</option><option value='Manufacturer3'>Manufacturer</option><option value='Version3'>Version</option><option value='NULL3'>NULL</option><option value='Ignore3'>Ignore</option></select></td></tr></table><table width=100% border=0><tr width=25% align=right><td><input type='text' id='Edition' value='Edition' DISABLED='disabled' style='background-color:White; color:Black;'></td><td width=20% align=left> <---- Matches to -----> <select name="dropdown3" onchange="fillSelect(this,categories[this.value],'dropdown4')"><option selected>Please Choose</option><option value='DeviceID'>DeviceID</option><option value='Product'>Product</option><option value='Manufacturer'>Manufacturer</option><option value='Version'>Version</option><option value='NULL'>NULL</option><option value='Ignore'>Ignore</option></select></td><td width=15% align=left> <select name="secondDD3" style="display: none;" onchange="fillSelect(this,categories[this.value],'secondDD4')"><option selected>Please Choose</option><option value='DeviceID2'>DeviceID</option><option value='Product2'>Product</option><option value='Manufacturer2'>Manufacturer</option><option value='Version2'>Version</option><option value='NULL2'>NULL</option><option value='Ignore2'>Ignore</option></select></td><td width=40% align=left> <select name="thirdDD3" style="display: none;" onchange="fillSelect(this,categories[this.value],'thirdDD4')"><option selected>Please Choose</option><option value='DeviceID3'>DeviceID</option><option value='Product3'>Product</option><option value='Manufacturer3'>Manufacturer</option><option value='Version3'>Version</option><option value='NULL3'>NULL</option><option value='Ignore3'>Ignore</option></select></td></tr></table><table width=100% border=0><tr width=25% align=right><td><input type='text' id='Version Number' value='Version Number' DISABLED='disabled' style='background-color:White; color:Black;'></td><td width=20% align=left> <---- Matches to -----> <select name="dropdown4" onchange="fillSelect(this,categories[this.value],'dropdown5')"><option selected>Please Choose</option><option value='DeviceID'>DeviceID</option><option value='Product'>Product</option><option value='Manufacturer'>Manufacturer</option><option value='Version'>Version</option><option value='NULL'>NULL</option><option value='Ignore'>Ignore</option></select></td><td width=15% align=left> <select name="secondDD4" style="display: none;" onchange="fillSelect(this,categories[this.value],'secondDD5')"><option selected>Please Choose</option><option value='DeviceID2'>DeviceID</option><option value='Product2'>Product</option><option value='Manufacturer2'>Manufacturer</option><option value='Version2'>Version</option><option value='NULL2'>NULL</option><option value='Ignore2'>Ignore</option></select></td><td width=40% align=left> <select name="thirdDD4" style="display: none;" onchange="fillSelect(this,categories[this.value],'thirdDD5')"><option selected>Please Choose</option><option value='DeviceID3'>DeviceID</option><option value='Product3'>Product</option><option value='Manufacturer3'>Manufacturer</option><option value='Version3'>Version</option><option value='NULL3'>NULL</option><option value='Ignore3'>Ignore</option></select></td></tr></table><table width=100% border=0><tr width=25% align=right><td><input type='text' id='Invoice Number' value='Invoice Number' DISABLED='disabled' style='background-color:White; color:Black;'></td><td width=20% align=left> <---- Matches to -----> <select name="dropdown5" onchange="fillSelect(this,categories[this.value],'dropdown6')"><option selected>Please Choose</option><option value='DeviceID'>DeviceID</option><option value='Product'>Product</option><option value='Manufacturer'>Manufacturer</option><option value='Version'>Version</option><option value='NULL'>NULL</option><option value='Ignore'>Ignore</option></select></td><td width=15% align=left> <select name="secondDD5" style="display: none;" onchange="fillSelect(this,categories[this.value],'secondDD6')"><option selected>Please Choose</option><option value='DeviceID2'>DeviceID</option><option value='Product2'>Product</option><option value='Manufacturer2'>Manufacturer</option><option value='Version2'>Version</option><option value='NULL2'>NULL</option><option value='Ignore2'>Ignore</option></select></td><td width=40% align=left> <select name="thirdDD5" style="display: none;" onchange="fillSelect(this,categories[this.value],'thirdDD6')"><option selected>Please Choose</option><option value='DeviceID3'>DeviceID</option><option value='Product3'>Product</option><option value='Manufacturer3'>Manufacturer</option><option value='Version3'>Version</option><option value='NULL3'>NULL</option><option value='Ignore3'>Ignore</option></select></td></tr></table><table width=100% border=0><tr width=25% align=right><td><input type='text' id='Supplier' value='Supplier' DISABLED='disabled' style='background-color:White; color:Black;'></td><td width=20% align=left> <---- Matches to -----> <select name="dropdown6" onchange="fillSelect(this,categories[this.value],'dropdown7')"><option selected>Please Choose</option><option value='DeviceID'>DeviceID</option><option value='Product'>Product</option><option value='Manufacturer'>Manufacturer</option><option value='Version'>Version</option><option value='NULL'>NULL</option><option value='Ignore'>Ignore</option></select></td><td width=15% align=left> <select name="secondDD6" style="display: none;" onchange="fillSelect(this,categories[this.value],'secondDD7')"><option selected>Please Choose</option><option value='DeviceID2'>DeviceID</option><option value='Product2'>Product</option><option value='Manufacturer2'>Manufacturer</option><option value='Version2'>Version</option><option value='NULL2'>NULL</option><option value='Ignore2'>Ignore</option></select></td><td width=40% align=left> <select name="thirdDD6" style="display: none;" onchange="fillSelect(this,categories[this.value],'thirdDD7')"><option selected>Please Choose</option><option value='DeviceID3'>DeviceID</option><option value='Product3'>Product</option><option value='Manufacturer3'>Manufacturer</option><option value='Version3'>Version</option><option value='NULL3'>NULL</option><option value='Ignore3'>Ignore</option></select></td></tr></table><table width=100% border=0><tr width=25% align=right><td><input type='text' id='Purchasing Officer' value='Purchasing Officer' DISABLED='disabled' style='background-color:White; color:Black;'></td><td width=20% align=left> <---- Matches to -----> <select name="dropdown7" onchange="fillSelect(this,categories[this.value],'dropdown8')"><option selected>Please Choose</option><option value='DeviceID'>DeviceID</option><option value='Product'>Product</option><option value='Manufacturer'>Manufacturer</option><option value='Version'>Version</option><option value='NULL'>NULL</option><option value='Ignore'>Ignore</option></select></td><td width=15% align=left> <select name="secondDD7" style="display: none;" onchange="fillSelect(this,categories[this.value],'secondDD8')"><option selected>Please Choose</option><option value='DeviceID2'>DeviceID</option><option value='Product2'>Product</option><option value='Manufacturer2'>Manufacturer</option><option value='Version2'>Version</option><option value='NULL2'>NULL</option><option value='Ignore2'>Ignore</option></select></td><td width=40% align=left> <select name="thirdDD7" style="display: none;" onchange="fillSelect(this,categories[this.value],'thirdDD8')"><option selected>Please Choose</option><option value='DeviceID3'>DeviceID</option><option value='Product3'>Product</option><option value='Manufacturer3'>Manufacturer</option><option value='Version3'>Version</option><option value='NULL3'>NULL</option><option value='Ignore3'>Ignore</option></select></td></tr></table><br /><table width="100%" border="0"> <tr> <td width=25% align=center> </td> <td width=25% align=center> </td> <td width=25% align=left><input name="Clean" align="center" type="submit" value="Cleanse"/></td> <td width=25% align=center> </td> </tr> </table> </form> </body> </html>
  16. ok thanks for that I have now made this invisible from the start with <select name="<?php echo "secondDD" .$c ?>" style="display: none;" onchange="fillSelect(this,categories[this.value],'<?php echo "secondDD" .$counter1++ ?>')"> my checkbox is in a string as follows echo "<tr width=100%><td width=25% align=right>&nbsp</td> <td width=20%> <input type=checkbox id=cbox name=cbox value=unselected onclick=show_hide(this.checked);>One to many</td> <td width=15%> </td> <td width=40%> </td></tr>"; any ideas
  17. ok guys I have broken this right down for ease of reading. I have a function which is suposed to show and hide my dropdown box but it doesnt fire, the alert fires but the dropdown wont disappear. any ideas echo "<tr width=100%><td width=25% align=right>&nbsp</td> <td width=20%> <input type=checkbox id=cbox name=cbox value=unselected onclick=show_hide(this.checked);>One to many</td> <td width=15%> </td> function show_hide( isChecked ) { alert("checkbox has been selected") ; document.getElementById('secondDD1').style.display = ( isChecked ? 'block' : 'none' ); document.getElementById('secondDD1').disabled = !isChecked; } <select name="<?php echo "secondDD" .$c ?>" onchange="fillSelect(this,categories[this.value],'<?php echo "secondDD" .$counter1++ ?>')"><?php echo "<option selected>Please Choose</option>"; echo "<option value='DeviceID2'>DeviceID</option>"; echo "<option value='Product2'>Product</option>"; ?></select>
  18. i have got this far after looking around on the web at other people with similar problems but it still will not show and hide the dropdowns. the alerts fire ok but no the rest any ideas function show_hide(){ var cbox = document.getElementById('cbox'); if (cbox.checked){ alert("checkbox has been selected") ; document.getElementById('thirdDD0').style.display = 'block'; document.getElementById('thirdDD0').disabled = false; document.getElementsByName('thirdDD0').style.display = 'block'; document.getElementsByName('thirdDD0').disabled = false; } else { alert("checkbox has been de-selected") ; document.getElementById('thirdDD0').disabled = true; document.getElementById('thirdDD0').style.display = 'none'; document.getElementsByName('thirdDD0').disabled = true; document.getElementsByName('thirdDD0').style.display = 'none'; } }
  19. thats what I have broken it down for
  20. I have broken it down if you are struggling to understand basically I want to show my dropdown boxes with this code function show_hide(o){ var cbox = document.getElementById('cbox'); if (cbox.checked){ alert("checkbox has been selected") ; document.getElementById('secondDD1').style.display = 'block'; document.getElementById('thirdDD1').style.display = 'block'; } else { alert("checkbox has been de-selected") ; document.getElementById('secondDD1').style.display = 'none'; document.getElementById('thirdDD1').style.display = 'none'; } but it doesnt work my dropdowns are still hidden and dont show up <select name="<?php echo "secondDD" .$c ?>" style="display:none" onchange="fillSelect(this,categories[this.value],'<?php echo "secondDD" .$counter1++ ?>')">
  21. what are code tags
  22. if your bored and not here to help then dont reply
  23. Hi Professionals. I have a webpage that pulls in a spreadsheet and creates some drop down boxes I also have a checkbox with a "one to many" option so in other words if user ticks the "one to many" option they can see so many dropdown boxes like so Drop1 <--matches--> Drop2, Drop3,Drop4 if the user unticks the "ony to many" option then they can only see dropdown boxes like so Drop1 <--matches--> Drop2 Can this be done I hope you understand what I mean, at the moment i just have a calc function to display an alert if it is checked or not Here is my coded page <head> <script type="text/javascript"> var categories = []; categories["startList"] = ["DeviceID","Manufacturer","Product","Version","NULL","Ignore"] categories["Manufacturer"] = ["DeviceID","Product","Version","NULL","Ignore"]; categories["DeviceID"] = ["Manufacturer","Product","Version","NULL","Ignore"]; categories["Product"] = ["DeviceID","Manufacturer","Version","NULL","Ignore"]; categories["Version"] = ["DeviceID","Manufacturer","Product","NULL","Ignore"]; categories["NULL"] = ["DeviceID","Manufacturer","Product","Version","NULL","Ignore"]; categories["Ignore"] = ["DeviceID","Manufacturer","Product","Version","NULL","Ignore"]; categories["startList2"] = ["DeviceID","Manufacturer","Product","Version","NULL","Ignore"] categories["Manufacturer2"] = ["DeviceID","Product","Version","NULL","Ignore"]; categories["DeviceID2"] = ["Manufacturer","Product","Version","NULL","Ignore"]; categories["Product2"] = ["DeviceID","Manufacturer","Version","NULL","Ignore"]; categories["Version2"] = ["DeviceID","Manufacturer","Product","NULL","Ignore"]; categories["NULL2"] = ["DeviceID","Manufacturer","Product","Version","NULL","Ignore"]; categories["Ignore2"] = ["DeviceID","Manufacturer","Product","Version","NULL","Ignore"]; categories["startList3"] = ["DeviceID","Manufacturer","Product","Version","NULL","Ignore"] categories["Manufacturer3"] = ["DeviceID","Product","Version","NULL","Ignore"]; categories["DeviceID3"] = ["Manufacturer","Product","Version","NULL","Ignore"]; categories["Produc3t"] = ["DeviceID","Manufacturer","Version","NULL","Ignore"]; categories["Version3"] = ["DeviceID","Manufacturer","Product","NULL","Ignore"]; categories["NULL3"] = ["DeviceID","Manufacturer","Product","Version","NULL","Ignore"]; categories["Ignore3"] = ["DeviceID","Manufacturer","Product","Version","NULL","Ignore"]; function calc() { //document.getElementById("cbox").checked=true var cbox = document.getElementById('cbox'); if (cbox.checked){ alert("checked") ; }else{ alert("Not checked.") } } function fillSelect(sel,ary,nxt){ if (ary&&sel.form){ var frm=sel.form,nme=sel.name.replace(/\d/g,""),i=Number(sel.name.replace(/\D/g,""))+1,nxt=frm[nxt],z0=0; while (frm[nme+i]){ frm[nme+i].length = 1; frm[nme+i].selectedIndex=0; i++; } for (;z0<ary.length;z0++){ nxt.options[z0+1]=new Option(ary[z0],ary[z0]); } nxt.selectedIndex=0; } } function getValue(isValue) { alert(isValue); } function init() { fillSelect(document.forms[0]['dropdown0'],categories['startList'],'dropdown0') fillSelect(document.forms[0]['secondDD'],categories['startList2'],'secondDD') fillSelect(document.forms[0]['thirdDD'],categories['startList3'],'thirdDD') } navigator.appName == "Microsoft Internet Explorer" ? attachEvent('onload', init, false) : addEventListener('load', init, false); function myfunction() { alert("Please ensure the file is in csv format"); } </script> </head> <?php include("header.php"); ?> <?php include("footer.php"); ?> <form action=""><?php $newname = $_GET['newname']; //The file that has been moved into the Uploads/ folder will need to be stripped here to retreive just the filename... $filename = basename($newname,"/"); //basename function strips off filename based on first forward slash "/" // Three counter variables necessary for looping purposes for dynmaic drop down box javascript client side functions $counter = 1; $counter1 = 1; $counter2 = 1; function ext($file) { return substr(strrchr($file,'.'),1); } if (isset($filename)) { $cfile = $filename; $cfile = ext($cfile); if ($cfile == 'csv'){ //do nothing its all good.. } else { ?><script type="text/javascript"> myfunction(); </script><?php header("refresh:1; url=preupload.php"); } } if (($handle = fopen($filename, "r")) !== FALSE) { $length = 1000; $delimiter = ","; ?> <?php $rows = 0; // ADDED while ( ( $data = fgetcsv( $handle, $length, $delimiter ) ) !== FALSE ) { if( $rows == 0 )// or rows = 3 using pipe command|| $rows == 3 ) // ADDED { $num = count($data); echo "<table width=100% border=0>"; echo "<tr width=100% align=center><td colspan=4>&nbsp</td></tr>"; echo "<tr width=100% align=center><td colspan=4 style=white-space:nowrap;width:100%;></td></tr>"; echo "<tr width=100% align=center><td colspan=4>Here we need info to assist user</td></tr>"; echo "<tr width=100%><td width=25%>&nbsp</td> <td width=20%>&nbsp</td> <td width=15%> </td> <td width=40%> </td></tr>"; echo "<tr width=100%><td width=25% align=right>&nbsp</td> <td colspan=3>By selecting one to many selection box will allow to split and cleanse the desired column into a maximum of 3 from the dropdown boxes</td></tr>"; echo "<tr width=100%><td width=25% align=right>&nbsp</td> <td colspan=3>By not selecting one to many will only allow for first set of dropdown boxes to cleanse data</td></tr>"; echo "<tr width=100%><td width=25% align=right>&nbsp</td> <td colspan=3>&nbsp</td></tr>"; echo "<tr width=100%><td width=25% align=right>&nbsp</td> <td width=20%><input type=checkbox id=cbox name=cbox value=unselected onclick=calc();>One to many</td> <td width=15%> </td> <td width=40%> </td></tr>"; echo "<tr width=100%><td width=25%> </td> <td width=20%>&nbsp</td> <td width=15%> </td> <td width=40%> </td></tr>"; echo "</table>"; for ($c=0; $c < $num; $c++) { echo "<table width=100% border=0>"; echo "<tr width=25% align=right><td>"; //Second array element populates the dropdown and calculates the number of columns from spreadsheet for ($d=0; $d < $num; $d++) { //echo "<option value='" .$data[$d]."'>" .$data[$d]."</option>"; } echo "<input type='text' id='".$data[$c]."' value='".$data[$c]."' DISABLED='disabled' style='background-color:White; color:Black;'>"; echo "</td>"; echo "<td width=20% align=left>"; ?> <---- Matches to -----> <select name="<?php echo "dropdown" .$c?>" onchange="fillSelect(this,categories[this.value],'<?php echo "dropdown" .$counter++ ?>')"><?php echo "<option selected>Please Choose</option>"; echo "<option value='DeviceID'>DeviceID</option>"; echo "<option value='Product'>Product</option>"; echo "<option value='Manufacturer'>Manufacturer</option>"; echo "<option value='Version'>Version</option>"; echo "<option value='NULL'>NULL</option>"; echo "<option value='Ignore'>Ignore</option>"; ?></select><?php echo "</td>"; echo "<td width=15% align=left>"; ?> <select name="<?php echo "secondDD" .$c?>" onchange="fillSelect(this,categories[this.value],'<?php echo "secondDD" .$counter1++ ?>')"><?php echo "<option selected>Please Choose</option>"; echo "<option value='DeviceID2'>DeviceID</option>"; echo "<option value='Product2'>Product</option>"; echo "<option value='Manufacturer2'>Manufacturer</option>"; echo "<option value='Version2'>Version</option>"; echo "<option value='NULL2'>NULL</option>"; echo "<option value='Ignore2'>Ignore</option>"; ?></select><?php echo "</td>"; echo "<td width=40% align=left>"; ?> <select name="<?php echo "thirdDD" .$c?>" onchange="fillSelect(this,categories[this.value],'<?php echo "thirdDD" .$counter2++ ?>')"><?php echo "<option selected>Please Choose</option>"; echo "<option value='DeviceID3'>DeviceID</option>"; echo "<option value='Product3'>Product</option>"; echo "<option value='Manufacturer3'>Manufacturer</option>"; echo "<option value='Version3'>Version</option>"; echo "<option value='NULL3'>NULL</option>"; echo "<option value='Ignore3'>Ignore</option>"; ?></select><?php echo "</td>"; echo "</tr>"; echo "</table>"; } } $rows++; // ADDED } fclose($handle); } ?></form>
  24. Hi Professionals. I am struggling with some code I wrote I calculate the number of column headings from a csv and produce populated dynamic dropdown boxes based on the headings and number of columns. on the other side I have dropdown box static values where underneath second dropdown changes based on the selection from the first dropdown. this works fine however only for the first two boxes EG if i have the first dropdown set to "DeviceID", "Manufacturer","Product","Version","NULL","Ignore" and i select "DeviceID" the second dropdown changes to "Manufacturer","Product","Version","NULL","Ignore" so "DeviceID" is no longer available for selection but in the third box or forth and so on "DeviceID" comes back which I do not want this available for selection as it has already been selected in the first box hope you understand what i mean Please find my code below <head> <script type="text/javascript"> var categories = []; categories["startList"] = ["DeviceID","Manufacturer","Product","Version","NULL","Ignore"] categories["Manufacturer"] = ["DeviceID","Product","Version","NULL","Ignore"]; categories["DeviceID"] = ["Manufacturer","Product","Version","NULL","Ignore"]; categories["Product"] = ["DeviceID","Manufacturer","Version","NULL","Ignore"]; categories["Version"] = ["DeviceID","Manufacturer","Product","NULL","Ignore"]; categories["NULL"] = ["DeviceID","Manufacturer","Product","Version","NULL","Ignore"]; categories["Ignore"] = ["DeviceID","Manufacturer","Product","Version","NULL","Ignore"]; function fillSelect(sel,ary,nxt){ if (ary&&sel.form){ var frm=sel.form,nme=sel.name.replace(/\d/g,""),i=Number(sel.name.replace(/\D/g,""))+1,nxt=frm[nxt],z0=0; while (frm[nme+i]){ frm[nme+i].length = 1; frm[nme+i].selectedIndex=0; i++; } for (;z0<ary.length;z0++){ nxt.options[z0+1]=new Option(ary[z0],ary[z0]); } nxt.selectedIndex=0; } } function getValue(isValue) { alert(isValue); } function init() { fillSelect(document.forms[0]['dropdown0'],categories['startList'],'dropdown0') } navigator.appName == "Microsoft Internet Explorer" ? attachEvent('onload', init, false) : addEventListener('load', init, false); function myfunction() { alert("Please ensure the file is in csv format"); } </script> </head> <form action=""><?php $newname = $_GET['newname']; //The file that has been moved into the Uploads/ folder will need to be stripped here to retreive just the filename... $filename = basename($newname,"/"); //basename function strips off filename based on first forward slash "/" $counter = 1; function ext($file) { return substr(strrchr($file,'.'),1); } if (isset($filename)) { $cfile = $filename; $cfile = ext($cfile); if ($cfile == 'csv'){ //do nothing its all good.. } else { ?><script type="text/javascript"> myfunction(); </script><?php header("refresh:1; url=preupload.php"); } } if (($handle = fopen($filename, "r")) !== FALSE) { $length = 1000; $delimiter = ","; ?> <?php $rows = 0; // ADDED while ( ( $data = fgetcsv( $handle, $length, $delimiter ) ) !== FALSE ) { if( $rows == 0 )// or i = 3 using pipe command|| $i == 3 ) // ADDED { $num = count($data); for ($c=0; $c < $num; $c++) { echo "<table width=100% border=0>"; echo "<tr width=33% align=right><td>"; ?><select name="<?php echo $data[$c]?>"><?php //Second array element populates the dropdown and calculates the number of columns from spreadsheet for ($d=0; $d < $num; $d++) { echo "<option value='" .$data[$d]."'>" .$data[$d]."</option>"; } ?></select><br /><?php echo "</td>"; echo "<td width=33% align=left>"; ?> <---- Matches to -----> <select name="<?php echo "dropdown" .$c?>" onchange="fillSelect(this,categories[this.value],'<?php echo "dropdown" .$counter++ ?>')"><?php echo "<option selected>Please Choose</option>"; echo "<option value='DeviceID'>DeviceID</option>"; echo "<option value='Product'>Product</option>"; echo "<option value='Manufacturer'>Manufacturer</option>"; echo "<option value='Version'>Version</option>"; echo "<option value='NULL'>NULL</option>"; echo "<option value='Ignore'>Ignore</option>"; //echo "<option value='" .$data[$e]."'>" .$data[$e]."</option>"; ?></select><?php echo "</td>"; echo "<td width=33%> </td>"; echo "</tr>"; echo "</table>"; } } $rows++; // ADDED } fclose($handle); } ?></form>
  25. ok all i want to do is show the column headings in a dropdown box which I have working, then I want to show the rest of the column rows underneath the drop down box I have the headings captured in the dropdown but the headings and rows are outputting to when I only want the rows without the heading as I am capturing that in the dropdown if that does not make sense I will try and explain in steps step 1: drop down populated working, step 2: then the headings again which i do not need anymore step 3: and finally the row step 4 : step 2 and step 3 repeating. I only need step 3 to show the rest of the rows HERE is my code <?php if (($handle = fopen($filename, "r")) !== FALSE) { $headings = array(); # MAD - Added ?><select name="Firstvalue" width="100" align="center" selected="Software Manufacturer"><option value='Software Manufacturer' selected="SELECTED">Choose</option><?php while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { if (empty($headings)) $headings = $data; # MAD - Added for ($c = 0; $c < count($headings); $c++) { echo "<option value='" .$headings[$c] ."'>" .$headings[$c] ."</option>"; //Only need first row in drop down box. EG the headings } ?></select><?php $num = count($data); echo "<p> <br /></p>\n"; $row++; for ($c=0; $c < $num; $c++) { echo $data[$c]; //Output all the rows echo " "; } } fclose($handle); } ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.