0

I've tried atleast a dozen different attempts at solving the problem of submitting form data to my database without reloading the page and scrolling to the top. With every attempted solution it continues to submit and scroll to the the top of the page in both chrome and safari.

//JAVA
<script type="application/javascript">
function doitall()
{
function validateHistory()
{
var x=document.getElementById("hist").value;
if(x==""}

   function(e)  {
       e.preventDefault();
       // Great isnt it
   return false;

   }
   </script>

// FORM
                <form action="search.php" onsubmit="return doitall();">
                     <td  bgcolor="#242424"><input class="textinput" type="text" value="" name ="hist" id ="hist" placeholder="Address" size="50"/></td><td bgcolor="#242424"><input type="hidden" value= name = id = size="100"/></td>
                    <td  bgcolor="#242424"><input type="hidden" value=<?php echo $num;?> name ="number" id ="number" size="50"/></td>
                    <td  bgcolor="#242424"><input type="hidden" value= name = id = size=""/></td>

                    <td bgcolor="#242424"><input type="submit" value="Submit onsubmit="return doitall();" class="buttonx"/>
4

1 に答える 1

0

JavaScriptにタイプミスがあるためです:

function validateHistory() {
    var x=document.getElementById("hist").value;
    if(x==""){ // You made a typo here
       function(e)  {
           e.preventDefault();
           // Great isnt it
           return false;
        }
    }
}

また、大量の不正な HTML があります。バリデーターを使用してみてください。

于 2013-10-09T05:59:55.300 に答える