javascript - I am trying to change the background image source to a url entered into a form box -


i trying change background image source url entered form box. have tried few things, , mashed code , yeah, no go. know enough code myself in trouble, not myself out of trouble. please help.

    <html>     <head>     <script>     function changebackground()     {var z = new image();      z.src = "<?=$varimage;?>";      document.body.background= z.src; }     </script>     <?php     if($errormessage != "")      {       echo("<p>there error:</p>\n");       echo("<ul>" . $errormessage . "</ul>\n");     }      else     {       $fs = fopen("mydata.csv","w+");       fwrite($fs,$varimage . ", \n");       fclose($fs);        header("location: thankyou.html");       exit;     }     ?>     <?php       if($_post['formsubmit'] == "submit")        {         $varimage = $_post['formimage'];       }     ?>      </head>     <body>     <script src="images.js" type="text/javascript"></script>     <form name="alternate" method="post" action="">        <input type="button" name="change" value="change"                                                             onclick="changebackground();">     </form>     </body>     </html> 

i try (assuming textbox contains url)

<script>     function changebackground(){         document.body.background = "<?=$varimage;?>";     } </script> 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -