DarkPrince2005 Posted May 3, 2010 Share Posted May 3, 2010 Can anyone maybe tell me why the submit isn't working? include 'inc/header.php'; echo '<form method="post" id="tracks" action="manage_artists.php"><a href="manage_artists.php?add">Add New</a>'; ?> <a href="javascript:;" onclick="submitform()">Delete Selected</a> <?php include 'inc/m_artists_list.php'; echo '</form>'; ?> <script type="text/javascript"> function submitform() { document.getElementById('tracks').submit(); } </script> Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 3, 2010 Share Posted May 3, 2010 Give the form a name attribute and use: document.forms.<form_name>.submit(); So if your form name is "tracks", it would be: document.forms.tracks.submit(); Quote Link to comment Share on other sites More sharing options...
DarkPrince2005 Posted May 3, 2010 Author Share Posted May 3, 2010 it still isn't working... include 'inc/header.php'; echo '<form method="post" name="tracks" id="tracks" action="manage_artists.php"><a href="manage_artists.php?add">Add New</a>'; ?> <a href="javascript:;" onclick="submitform()">Delete Selected</a> <?php include 'inc/m_artists_list.php'; echo '</form>'; ?> <script type="text/javascript"> function submitform() { document.forms.tracks.submit(); } </script> Quote Link to comment Share on other sites More sharing options...
yperevoznikov Posted May 3, 2010 Share Posted May 3, 2010 Hi DarkPrince2005, Can you send html code of all page? Thanks. Quote Link to comment Share on other sites More sharing options...
DarkPrince2005 Posted May 3, 2010 Author Share Posted May 3, 2010 <?php // NB Stuff - Same on all pages // include 'inc/db.php'; require('classes/class.database.php'); require('classes/class.session.php'); require('classes/class.users.php'); include 'classes/class.general.php'; $database = new Database($host,$user,$pass,$dbname); if (!$database->connect()) die('Could not resolve database'); $session = new Session; $page_title = "Manage Artists"; include 'inc/simple_forms.php'; // POST VARS TO PHP VARS $code = isset($_POST['code']) && $_POST['code'] !== '' ? $_POST['code'] : ''; $name = isset($_POST['name']) && $_POST['name'] !== '' ? $_POST['name'] : ''; $m_artist_add_form = ' <div class="m_artist_add_form"> <form method="post" enctype="multipart/form-data" action="manage_artists.php?add"> Artist Code: <input type="text" name="code" value="'.$code.'" /><br /> Artist Name: <input type="text" name="name" value="'.$name.'" /><br /> <input class="button" type="submit" name="submitted" value="Save"> </form> </div> '; // END of NB Stuff // // Check if logged in // if($session->logged_in) { if(isset($_POST["search"]) && $_POST["searchfield"] != ""){ $sql = "select * from artists where `name` like '%".$_POST["searchfield"]."%'"; echo $sql; $query = mysql_query($sql); if(mysql_num_rows($query)<1) { //$sql = "select * from `artists`"; if($query = $database->query($sql)) { $genre = mysql_query("select * from genre order by name"); include "inc/header.php"; ?> <table width="100%" cellpadding="5" cellspacing="0"> <tr><td align="left" bgcolor="#cccccc" height="22"> </td><td align="right" bgcolor="#cccccc" height="22"><span style="font-size:12px;">Search:</span> <input type="text" name="searchfield" /><input type="submit" name="search" value="Go" /></td></tr></table> <?php $result = $database->getRecordSet($sql); echo "<div class='list'><br /><br /><table cellpadding='1' cellspacing='0'>"; echo " <tr> <td width='4%'> </td> <td width='10%' class='bold'> Artist Code </td> <td width='20%' class='bold'> Artist Name </td> <td width='20%' class='bold'> Date Added </td> <td width='5%'> Edit </td> <td width='5%'> </td> </tr> <tr> <td colspan='6' align='center' height='30'>NO RESULTS FOUND</td> </tr> "; //close up the table echo "</table><br />"; exit; } }else{ include "inc/artists_search.php"; exit; } } if(isset($_POST["delete"])) { if($_POST["delete"] != ""){ $err = 0; foreach($_POST["delete"] as $key => $id) { $sql1=mysql_query("select * FROM artists WHERE id = '".(int)$id."' limit 0,1") or die(mysql_error("Error")); $a = mysql_fetch_array($sql1); $R=mysql_fetch_array($sql1); $sql=mysql_query("DELETE FROM artists WHERE id='".(int)$id."'") or die(mysql_error()); if(!$sql){ $err++; } } if($err==0) { header('Refresh: 2; url=manage_genres.php'); include 'inc/header.php'; echo $artists_mdelete_success; exit; } else { echo "Deletion failed"; var_dump($database->error()); } } else { echo "please select at least one row, to delete it"; } } if(isset($_GET['add'])) { // ADD NEW TRACK INCLUDE include 'inc/m_artists_add.php'; } elseif(isset($_GET['delete'])) { // DELETE TRACK INCLUDE include 'inc/m_artists_delete.php'; } else { // SHOW TRACKS LIST INCLUDE include 'inc/header.php'; echo '<form method="post" name="tracks" id="tracks" action="manage_artists.php"><a href="manage_artists.php?add">Add New</a>'; ?> <a href="javascript:;" onclick="submitform()">Delete Selected</a> <?php include 'inc/m_artists_list.php'; echo '</form>'; ?> <script type="text/javascript"> function submitform() { document.forms.tracks.submit(); } </script> <?php } $database->disconnect(); } else { // If not logged in include 'inc/header.php'; echo $login_msg; echo $login_form; } // End of logged in checking include 'inc/footer.php'; ?> Quote Link to comment Share on other sites More sharing options...
yperevoznikov Posted May 4, 2010 Share Posted May 4, 2010 Hi DarkPrince2005. Hmm.. That's very strange.. And it's code doesn't work? Can you try somethind like this: <script type="text/javascript"> function submitform() { //document.forms.tracks.submit(); document.getElementById("tracks").submit(); } </script> If this doesn't help too - show code that you receive in browser (View Page Source in FF for example). Thanks. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.