2016-03-23 16 views
0

PHPで入力フィールドに名前を入力したフォルダを作成するサービスを作成しています。JavaScript URLフォームが機能しない、またはリダイレクトしない理由

<?php 
 
function recurse_copy($src,$dst) { 
 
    $dir = opendir($src); 
 
    @mkdir($dst); 
 
    while(false !== ($file = readdir($dir))) { 
 
     if (($file != '.') && ($file != '..')) { 
 
     if (is_dir($src . '/' . $file)) { 
 
      recurse_copy($src . '/' . $file,$dst . '/' . $file); 
 
     } 
 
     else { 
 
      copy($src . '/' . $file,$dst . '/' . $file); 
 
     } 
 
     } 
 
    } 
 
closedir($dir); 
 
} 
 
    
 
$src = "./xe7"; 
 
    
 

 
$dst = $_POST['foldername']; 
 
    
 
recurse_copy($src,$dst); 
 
?> 
 
<link rel="stylesheet" type="text/css" href="style.css" /> 
 
<div> 
 
<body onload="timer=setTimeout('removeControls();',3)"> 
 
<h1>Drawblog</h1> 
 
<div class="FAQ" style ="box-shadow: 1px 1px 3px rgba(0,0,0,0);"> 
 
    <a href="#hide1" class="hide" id="hide1">Control panel</a> 
 
    <a href="#show1" class="show" id="show1">-</a> 
 
     <div class="list" style ="box-shadow: 1px 1px 3px rgba(0,0,0,0);"> 
 
<form method="post" > 
 
<input type="text" name="foldername" id ="togl"> 
 

 
<input type="submit" name="submit" id = "sm2" value="Create panorama" onclick ="newDoc();"> 
 

 
    
 
    <script type="text/javascript"> 
 
function newDoc() { 
 
    var folder = document.getElementById("togl").value; 
 
    var url = "http://hokuco.com/test/" + folder + "/toggle.php"; 
 
    window.location.assign(url) 
 
}; 
 
    </script> 
 
\t </form> 
 
<h3>Or,</h3> 
 
<h2>Login with an access code(the account you just typed into the box above, or a code someone shared with you)</h2> 
 
    <input type="text" id="field" /> 
 
    <button id="submit">Go</button> 
 
<link rel="stylesheet" type="text/css" href="style.css" /> 
 
    <script type="text/javascript"> 
 
document.getElementById("submit").addEventListener("click", function(){ 
 
    var folder = document.getElementById("field").value; 
 
    var url = "http://hokuco.com/test/" + folder + "/index.html"; 
 

 
    window.location.href = url; 
 
}); 
 
    </script> 
 
\t   </div> 
 
</div> 
 
<h1>&nbsp;</h1> 
 
<h1>&nbsp;</h1> 
 
<p>make shocking panoramas in minutes, no account needed</p> 
 
<br/> 
 
<br/> 
 
<br/> 
 
<br/> 
 
<p>special thanks to:</p> 
 
\t \t <div id="info"><a href="http://threejs.org" target="_blank">three.js css3d</a> - panorama.</div> 
 

 
\t <h5>a hokuco company</h5> 
 
</div> 
 
<style> 
 
.FAQ { 
 
    vertical-align: top; 
 
    height:auto !important; 
 
} 
 
.list { 
 
    display:none; 
 
    height:auto; 
 
    margin:0; 
 
    float: left; 
 
} 
 
.show { 
 
    display: none; 
 
} 
 
.hide:target + .show { 
 
    display: inline; 
 
} 
 
.hide:target { 
 
    display: none; 
 
} 
 
.hide:target ~ .list { 
 
    display:inline; 
 
} 
 

 
/*style the (+) and (-) */ 
 
.hide, .show { 
 
\t width: 45px; 
 
\t height: 30px; 
 
\t font-size: 20px; 
 
\t color: #000; 
 
\t text-shadow: 0 1px 0 #666; 
 
\t text-align: center; 
 
\t text-decoration: none; 
 
\t background: #ffffff; 
 
\t opacity: .95; 
 
    border-bottom: thick solid #000000; 
 
\t margin-right: 0; 
 
\t float: left; 
 
\t margin-bottom: 25px; 
 
} 
 

 
.hide:hover, .show:hover { 
 
\t text-decoration: none; 
 
\t opacity: 1; 
 
    \t color: #000; 
 
    background: #ffffff; 
 
\t margin-bottom: 25px; 
 
} 
 

 
.list p{ 
 
    height:auto; 
 
    margin:0; 
 
} 
 
.question { 
 
\t float: left; 
 
\t height: auto; 
 
\t width: 90%; 
 
\t line-height: 20px; 
 
\t padding-left: 20px; 
 
\t margin-bottom: 25px; 
 
} 
 

 
</style>

私はページがここで先ほど作成したフォルダ(およびファイルと呼ばれるtoggle.php)に をリダイレクト私はJavaScriptであることを確認するために一緒に少しJavaScriptを考え出すしようとしています

+1

作成する必要があるフォルダにどのようにリダイレクトできますか? – Yuri

+0

ありがとう私はそんなばかげた過ちを犯した、時々私はイムjin doin jsと思うdoz js –

+0

それは変わった...それはphpでここで仕事が悪い投稿全部... –

答えて

0
<form id="form"> 
<input type="text" id="mysearch-text"> 
<input type="submit" value="Submit"> 

<script> 
window.onload = function() { 
    document.getElementById("form").onsubmit = function() { 
     var filmName = document.getElementById("mysearch-text").value; 
     alert(filmName); 
     if (filmName == "parker") window.location.href = "http://www.w3fools.com"; 
     else alert("hello"); 
     return false; //prevent the default behavior of the submit event 
    } 
}   

+0

質問コードがうまくいかなかった理由と、このコードがどうやって解決するのか説明してください。 – Aaronepower

+0

また、plzはコードが私のコードに合致しないようにします... –

関連する問題