SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    Non-Member
    Join Date
    Oct 2005
    Posts
    205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Form not working

    Hello, my form does not work in firefox (nor IE either since i have been messign with it)

    You can see it in action at ebookwizardpro.com. Log in as testing, testing - go to edit ebook, click next and on the artilce selection process is where it does not work. When you try to delete articles it does nothing.

    I had this working in IE before... please help!!!


    Code:
    <?
    	$require_login = true;
    	set_include_path( "../" );
    	include( "includes/header.php" );
    	restore_include_path();
        $bookid = getApplicationVar( "Users", "currentbook" );
        $book = mysql_object( "SELECT * FROM ebooks WHERE userid = '$user->userid' AND id = '$bookid'" );
        // new strings check for user created articles and count them
    	$query_new = $_POST["query_new"];
    
    	echo"$query_new";
    
    
        // get user submitted articles
    
    
    	if( !$book->id ){
    		header( "Location: build.php" );
    	}
    
    	$results = getset( "SELECT * FROM ebook_articles WHERE bookid = '$bookid'" );
    
    	$num = 0;
        // get current articles
        $article_count = "SELECT * FROM ebook_articles WHERE bookid = $bookid";
       	$article_count_result = mysql_query($article_count,$maindb) or die ("Couldn't execute article count query!");
    
        $total = mysql_num_rows($article_count_result);
    
        $article_count2 = "SELECT * FROM ebook_articles WHERE bookid = $bookid AND source = 1";
       	$article_count_result2 = mysql_query($article_count2,$maindb) or die ("Couldn't execute article count2 query!");
    
        $total2 = mysql_num_rows($article_count_result2);
    
    ?>
    <!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd">
    <html>
    <head>
    <TITLE>Ebook Wizard Pro</TITLE>
    <META name="description" content="The easiest ebook writing solution for increasing subscribers to your list.  Professional quality pdf e-books with your links, at the click of a button.">
    <META name="keywords" content="free ebooks,e-books,pdf ebook">
    <META name="subject" content="ebooks and pdf">
    <META name="robots" content="index,follow,all">
    <META name="Revisit-after" content="5 days">
    <META name="Rating" content="general">
    <META http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <link rel="stylesheet" href="/styles.css">
    <script language="javascript" src="/js/general.js"></script>
    <script language="javascript">
    	function selectall(){
    		form = document.forms_test[0];
    		for( var i = 0; i < form.length; i++ ){
    			var frmObj = form.elements[i];
    			if( frmObj.type == 'checkbox' ){
    				frmObj.checked = true;
    			}
    		}
    	}
    
    	function submitForm(){
    		numchecked = checkCount();
    		if( numchecked < 10 ){
    			alert( "You must select 10 articles" );
    		}else if( numchecked > 10 ){
    			alert( "You may not select more than 10 articles for your ebook" );
    		}else{
    			form = document.forms_test[0];
    			var cmdEle = document.getElementById( "cmd" );
    			cmdEle.value = "saveFinal";
    			form.submit();
    		}
    	}
    
        	function submitForm2(){
    		numchecked = checkCount();
    
           		if( numchecked > 10 ){
    			alert( "You may not select more than 10 articles for your ebook" );
    		}else{
    			form = document.forms_test[0];
    			var cmdEle = document.getElementById( "cmd" );
    			cmdEle.value = "getmorearticles";
    			form.submit();
    		}
    	}
    
    	function checkCount(){
    		form = document.forms_test[0];
    		var numchecked = 0;
    		for( var i = 0; i < form.length; i++ ){
    			var frmObj = form.elements[i];
    			if( frmObj.type == 'checkbox' ){
    				if( frmObj.checked == true ){
    					numchecked++;
    				}
    			}
    		}
    		return numchecked;
    	}
    
    	function checkOnCheck(){
    		numchecked = checkCount();
    		if( numchecked > 10 ){
    			alert( "You have already selected 10 articles" );
    			return false;
    		}else{
    			return true;
    		}
    	}
    </script>
    </head>
    <body>
    <table border="0" cellpadding="0" cellspacing="0" width="780" style="border:1px solid #000000;">
      <? include( "../includes/sitetop.php" )?>
      <tr>
        <td align="center" valign="top"><br>
          <table width="780" border="0" align="center" cellpadding="2" cellspacing="0">
            <tr>
              <td width="150" align="center" valign="top">
                <? include( "includes/menu.php" ); ?></td>
              <td width="622" align="center" valign="top"><br>
    		  <form action="/useradmin/ebookprocess.php" method="post" name="forms_test">
    		  <input type="hidden" name="cmd" id="cmd" value="saveresearch">
                <table width="550" border="0" align="center" cellpadding="2" cellspacing="0" class="contenttable">
                  <tr>
                    <td class="title">Build My E-Book: Step Three - Final Article Selection </td>
                  </tr>
                  <tr>
                    <td>
                    <?
                    $needed = 10 - $total;
                    echo"
                      <p>You currently have $total articles.  You will need to add $needed more to proceed.</p>";
                      ?>
    				  <p class="bold" align="center">Project Name:  <?=stripslashes( $book->name )?></p>
                      <table width="500" border="0" align="center" cellpadding="2" cellspacing="0">
                        <tr>
                          <td colspan="2" align="left" valign="top" class="title">User Submitted Articles</td>
                          </tr>
                         <?
                             for( $i = 1; $i <= 10; $i++ ){
                           while ($row = mysql_fetch_array($article_count_result2)) {
    
                          $title = $row["title"];
                          $id = $row["id"];
    
                        ?>
                         <tr>
                         <td width="50" align="center" valign="top"><input name="user_articles[]" type="checkbox" class="radio" id="$id" value=<? echo "\"$title\"";?> onClick="if( this.checked == true ) return checkOnCheck();" <? if( $num <= 10 ) echo "checked"; ?>></td>
                          <? echo"
                          <td width=442 align=left valign=top>$title  </td>
                         </tr>";
                              }
                             }
                             ?>
                             <tr>
                       <td class="title" colspan="2">saved articles from search</td>
                       </tr>
    
    					  <?
                         /*
                          $thisbook = mysql_fetch_object( mysql_array( "select * from article_database where id = '$row->articleid'", $fqdb ) );
                         if ($thisbook !="") {*/
    
                         $maindb_select =  "SELECT * FROM ebook_articles WHERE bookid = '$bookid' AND source = '0'";
                         $maindb_select_result = mysql_query($maindb_select,$maindb) or die ("Couldn't maindb query!");
    
                         while ($row2 = mysql_fetch_array($maindb_select_result)) {
    
    
                         $articleid = $row2["articleid"];
                         $text = $row2["description"];
                         $title = $row2["title"];
                         $author = $row2["author"];
    
    
                         
                         $title = stripslashes($title);
                         $author = stripslashes($author);
                       
    					$text = htmlentities($text);
    						//$text = addslashes($text);
                        //$input_fields = "<input type=\"hidden\" name=\"text[]\" value='".$text."'>\n";
                        $input_fields = "<input type=\"hidden\" id=\"author[]\" name=\"author[]\" value=\"$author\">\n";
                        $input_fields .= "<input type=\"hidden\" id=\"title[]\" name=\"title[]\" value=\"$title\">\n";
    
                        echo $input_fields;
    
    
    
                         ?>
    
    
                          <td width="50" align="center" valign="top"><input name="fqdb_articles[]" type="checkbox" class="radio" id="fqdb_articles[]" value="<?=$articleid?>" onClick="if( this.checked == true ) return checkOnCheck();" <? if( $num <= 10 ) echo "checked"; ?>></td>
                          <?
                          echo"
                          <td width=\"442\" align=\"left\" valign=\"top\"><a href=\"previewarticle.php?id=$id\" target=\"_blank\">$title</a></td>
                          </tr>
                          ";   ?>
    
    
    					  <? } ?>
                      </table>
                      <p>&nbsp;</p>
                    </td>
                  </tr>
                  <tr>
                    <td align="center" valign="middle" class="title"><a href="#" onClick="submitForm(); return false;"><img src="/images/usearticles.gif" width="200" height="50" border="0"></a>
                    &nbsp;OR&nbsp;<a href="#" onClick="submitForm2(); return false;">
                    <input type="image" src="/images/detearticlegoback.gif" width="200" height="50" border="0"></a></td>
                  </tr>
                </table>
    			</form>
              </td>
            </tr>
          </table>
          <br>
        </td>
      </tr>
      <? include( "../includes/footer.php" )?>
    </table>
    </body>
    </html>

  2. #2
    SitePoint Zealot mrWoot's Avatar
    Join Date
    Jan 2004
    Location
    Wisconsin
    Posts
    131
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Fix you HTML and Javascript errors first. That will help find the problem.

    I know one error is at
    PHP Code:
    <td width="50" align="center" valign="top"><input name="user_articles[]" type="checkbox" class="radio" id="$id" value=<? echo "\"$title\"";?> onClick="if( this.checked == true ) return checkOnCheck();" <? if( $num <= 10 ) echo "checked"?>></td>
    You don't echo $id

  3. #3
    Non-Member
    Join Date
    Oct 2005
    Posts
    205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello, thanks for your response. I already fixed the $id error. I noticed it shortly after I posted.

    What next?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •