简体   繁体   中英

javascript statements not working… and getting 'failed to load resource' error

<?
echo '<html>
<script language=javascript>
function validate()
{
    alert("validate");
    document.form1.action="validate.php";
    document.form1.submit();
    return false;
}
function del()
{
    alert("delete");
    document.form1.action="delete.php";
    document.form1.submit();
    return false;
}
</script>

<style>
.id
{
    background-image:url("http://localhost/troubleshoot/imges/bg1.jpg");
    background-position:center;
    background-repeat:no-repeat;
    background-size:2000px 2000px;
    border-radius:5px;
}
table
{
    border-radius:5px;
}
.id1
{
    border-radius:5px;
    background-color:DDDDDD;
}
id3
{
    padding-top:5em;
    padding-bottom:5em;
    height:40px;
}
.id2
{
    text-shadow:0px 0px 5px black;
    color:#FFFFDD;  
    font-size:20;
    font-style:bold;
}
</style>
<body> 
<table width=70% align=center>
    <td><img src="http://localhost/troubleshoot/imges/banner.jpg" height=150 width=100% style="border-radius:5px">
</table>
<table width=70% bgcolor=#3E638C align="center" border=0 style="border-radius:5px;" cellspacing=20>
<tr><td align="center"><a href="home.html"><font color=white>Home</a></td>
       <td align="center"><a href="about.html"><font color=white>About Us</a></td>  
       <td align="center"><a href="articles.html"><font color=white>Articles</a></td>
       <td align="center"><a href="work.html"><font color=white>Work</a></td>
       <td align="center"><a href="contact.html"><font color=white>Contact Us</a></td>
</tr></table>';
$c=mysql_connect("localhost","root","");
mysql_select_db("troubleshoot",$c);
$q=mysql_query("select * from clientbugandsol");
$count=mysql_num_rows($q);
echo "<table width=70% align=center border=1 style='border-radius:5px;'>
<tr><td width=100% align=center> <font face=algerian color='#A52A2A'>There are $count bugs received</tr>
<tr><td>";
$i=1;$j=0;
while($s=mysql_fetch_row($q))
{
    echo "<form name=form1 method=post>
<table width=90% bgcolor='#6CDAF5' align=center>
        <tr><th align=left> Bug $i: </tr>
        <tr><td>Username: <td> <input type=text value='$s[0]' name=username> </td></tr>
        <tr><td>User email-id: <td><input type=text value='$s[1]' name=email> </td></tr>
        <tr><td>User Contact-no :<td><input type=text value='$s[2]' name=contactno> </td></tr>
        <tr><td>Bug: <td><textarea rows=5 cols=40 name=bug>$s[3]</textarea></td></tr>
        <tr><td>Bug-Reason: <td><textarea rows=5 cols=40  name=text1>$s[4]</textarea></td></tr>
        <tr><td>Bug-Solution:<td><textarea rows=5 cols=40 name=text2>$s[5]</textarea></td></tr>
        <tr><td>Updated-date:<td><input type=text value='$s[6]' name=date></td></tr>
        <tr><td width=100% align=right colspan=2><input type=submit value='add this bug with main bugs'  OnClick='validate()'>
        <input type=submit name=delete  value='delete this bug' OnClick='del()'></tr>
        </table><br></form>";

}

echo '  

</body>
</html>';
?>
<html>

</html>

i am getting failed to load resource error.. while execute this code, in javascript document.form1.action doesnot work out.... so it doesnot redirect to another page.. what i have to clear this... pls help me

Aside from all the problems with your html structure, I suspect the root problem you're running into is that your browser can't find the delete.php file, which I assume is in the same directory that the file this code is from is in. While on a server that form of path-relative addressing will work, generally speaking browsers will prevent loading of files from the host file system for security purposes.

Change your action to access delete.php via your localhost web server (ie http://localhost/troubleshoot/delete.php ) and you should be able to load the file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM