![]() |
|
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Expert Programmer
|
javascript function over table
Ok, so I wrote some code to make links act like the submit button to a form. I wrote a test file (test.php) which used analyze.php to work with the form data. When I put it up to the scale on the main page the javascript stopped work, so I'm thinking it's because I'm putting it into a table, below is the code. Any ideas or thoughts is much appreciated! Thanks guys!
test.php [php] <html> <script language="JavaScript" type="text/javascript"> <!-- function submit ( selectedType ) { document.form1.value.value = selectedType ; document.form1.submit() ; } --> </script> <form name="form1" method="post" action="analyze.php"> <input type="hidden" name="value" /> <a href="javascript:submit('Delete')">Delete</a> or <a href="javascript:submit('Edit')">Edit</a>or <a href="javascript:submit('Share')">Share</a> </form> </html> [/php] analyze.php [php] <html> <body> <?php $file = $_POST['value']; echo $file; if ($file == 'Delete') { echo "Delete has been chosen."; } elseif ($file =='Edit') { echo "Edit function has been chosen."; } elseif ($file =='Share') { echo "Share function has been chosen."; } else { echo "Nothing has been chosen."; } ?> </body> </html> [/php] And when I use test.php everything works, now below is the code that uses it in a table and doesn't work. I main.php (The entire file is not included. If you think the problem could be in the rest of the file, let me know, but I think it's a waste of space and tiem for you guys to look at) [php] html> <body> <script language="JavaScript" type="text/javascript"> <!-- function submit ( selectedType ) { document.form1.value.value = selectedType ; document.form1.submit() ; } --> </script> <table> <tr><td> <? if($session->logged_in){ echo "<h1>Logged In</h1>"; echo "Welcome <b>$session->username</b>!<br><br>" ."[<a href=\"userinfo.php?user=$session->username\">My Account</a>] " ."[<a href=\"useredit.php\">Edit Account</a>] " ."[<a href=\"saver.php\">New Document</a>] "; if($session->isAdmin()){ echo "[<a href=\"admin/admin.php\">Admin Center</a>] "; } echo "[<a href=\"process.php\">Logout</a>]<br><br><br>- [$session->username's Files] -<br>"; // -------------------------------------------------------------------------------------------------- Directory Code // This is the directory to list files for. $theDirectory = $session->username; // Do you want to show directories? change to false to hide directories. $listDirectories = false; echo "</ br></ br>"; if(is_dir($theDirectory)) { // Title for top of columns echo "<table><tr> <td><u>Name</u></td> <td><u>Size</u></td> <td><u>Action</u></td> <td><u>Action</u></td> <td><u>Action</u></td> <td><u>Action</u></td> </tr>"; $dir = opendir($theDirectory); while(false !== ($file = readdir($dir))) { $type = filetype($theDirectory ."/". $file); if($listDirectories || $type != "dir") { echo "<tr><td>" . $file . "</td>"; // echo "<td>" . $type . "</td>"; echo "<td>"; if($type == "file") $fileSize = filesize($theDirectory."/".$file)/1024; // Divide 1024 to get into kilobytes echo number_format($fileSize, 2); // Limit the decimals to two places echo " Kilobytes."; echo "</td>"; echo "<td><a href='".$theDirectory."/".$file."'>View</a></td>"; // Works //////////////////////////////////////////////////////////////////////////////// echo "<form name\"form1\" method=\"post\" action=\"analyze.php\">"; echo "<input type=\"hidden\" name=\"value>"; echo "<td><a href=\"javascript:submit('Edit')\">Edit</a></td>"; // Doesn't Work echo "<td><a href=\"javascript:submit('Delete')\">Delete</a></td>"; // Doesn't Work echo "<td><a href=\"javascript:submit('Share')\">Share</a></td>"; // Doesn't Work echo "</form>"; echo "</tr>"; //////////////////////////////////////////////////////////////////////////// } } closedir($dir); echo "</table>---"; } else { echo $theDirectory . " is not a directory"; } //----------------------------------------------------------------------------------------------------------------------------------------------End Directory Code [/php] I enclosed what I think to be the problematic area in /////////////////////////// |
|
|
|
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Compiling Maverik 6.2 (from C) | megamind5005 | C | 16 | May 3rd, 2006 6:41 PM |
| libraries | matko | C | 1 | Jan 22nd, 2006 3:12 PM |
| Php Postgresql Class | Pizentios | Show Off Your Open Source Projects | 15 | Jun 28th, 2005 10:55 AM |
| Jackpot game | zorin | Visual Basic | 3 | Jun 10th, 2005 2:19 PM |
| airport Log program using 3D linked List : problem reading from file | gemini_shooter | C++ | 0 | Mar 2nd, 2005 5:12 PM |