Javascript 表单-提交后获取空白返回值

Javascript 表单-提交后获取空白返回值,javascript,php,html,Javascript,Php,Html,我正在尝试使用window.open方法将表单输入值填充到新的弹出窗口中。我设法得到了弹出窗口,但是,输入没有通过,页面返回没有值。请告知如何修复此问题。提前谢谢。我是网络开发的新手 剧本 function validate(){ <!-- HTML form validation done by JavaScript. --> <!-- variable object used to represent the questions in the form -->

我正在尝试使用window.open方法将表单输入值填充到新的弹出窗口中。我设法得到了弹出窗口,但是,输入没有通过,页面返回没有值。请告知如何修复此问题。提前谢谢。我是网络开发的新手

剧本

function validate(){ <!-- HTML form validation done by JavaScript.  -->

<!-- variable object used to represent the questions in the form  -->

var x1=document.getElementById("text1");
var x2=document.getElementById("text2");
var x3=document.getElementById("hobbies");
var x4=document.getElementById("Gender");


<!-- if used to verify if no information given the the alert will pop up upon submission -->
if (x1.value == "" || x2.value == "" || x3.value == "" || x4.value == "") 

{
alert("No blank values allowed")
return false;
}
else
{
window.open('https://quiet-odyssey-258110.appspot.com/'+self.location,'mywin',
'left=20,top=20,width=500,height=500,toolbar=1,resizable=0');
}

}

</script>
函数验证(){
var x1=document.getElementById(“text1”);
var x2=document.getElementById(“text2”);
var x3=document.getElementById(“爱好”);
var x4=document.getElementById(“性别”);
如果(x1.value==“”| | x2.value==“”| | x3.value==“”| | x4.value==“”)
{
警报(“不允许空白值”)
返回false;
}
其他的
{
打开窗户https://quiet-odyssey-258110.appspot.com/“+self.location,'mywin',
‘左=20,上=20,宽=500,高=500,工具栏=1,可调整大小=0’;
}
}
形式


全名:

电邮地址:

爱好:

阅读
绘画
旅行
烘焙

性别

男性
女性

登记 重置
PHP

祝贺你

您的全名:
您的电子邮件地址:
你的爱好:
您的性别:

您试图使用
$\u get[“text1”]
获取参数,但未在
窗口中传递它们。打开
url查询字符串。
要在
$\u GET[“text1”]
中包含某些内容,您应该在url中包含类似于
?text1=某些值的内容

window.open(“
?text1=”+x1+”&email=“+x2+”
,“mywin”,
‘左=20,上=20,宽=500,高=500,工具栏=1,可调整大小=0’

您没有定义表单提交的方法。首先,您在HTML代码中提到了您的方法

 <form onsubmit="return validate()" method="post" action="">

<!-- label used to tag the field name -->
<label>Full Name : </label>
<input type= "text" id="text1" name= "text1" placeholder="Enter your Full Name here..."><br>

<label>Email address : </label>
<input type= "email" id="text2" name= "email" placeholder="Enter your Email Address here..." ><br><br>

<label>Hobbies : </label><br><br>
<input type="checkbox" id="hobbies" name="hobbies[]" value="Reading"/>Reading<br/>
<input type="checkbox" id="hobbies" name="hobbies[]" value="Painting"/>Painting<br/>
<input type="checkbox" id="hobbies" name="hobbies[]" value="Traveling"/>Traveling<br/>
<input type="checkbox" id="hobbies" name="hobbies[]" value="Baking"/>Baking<br/><br/>

<label>Gender</label><br><br>  <!-- drop donw list has been used to choose gender and locations -->
     <input type="radio" id="Gender" name="gender" value="Male" > Male<br>
    <input type="radio"
    </hr>
    <button type="submit" class="registerbtn" >Register</button>
    <button type="reset" class="Reset">Reset</button>   

</form>

检查您的
id
姓名&您正在呼叫的姓名。。。
Congratulations !!!<br/><br/>
Your Full Name : <?php echo $_GET["text1"]; ?><br/>
Your Email address : <?php echo $_GET["email"]; ?><br/>
Your Hobbies : <?php foreach($_GET['hobbies'] as $selected){
echo $selected.", ";};?><br/>
Your Gender : <?php echo $_GET["gender"]; ?><br/>
 <form onsubmit="return validate()" method="post" action="">

<!-- label used to tag the field name -->
<label>Full Name : </label>
<input type= "text" id="text1" name= "text1" placeholder="Enter your Full Name here..."><br>

<label>Email address : </label>
<input type= "email" id="text2" name= "email" placeholder="Enter your Email Address here..." ><br><br>

<label>Hobbies : </label><br><br>
<input type="checkbox" id="hobbies" name="hobbies[]" value="Reading"/>Reading<br/>
<input type="checkbox" id="hobbies" name="hobbies[]" value="Painting"/>Painting<br/>
<input type="checkbox" id="hobbies" name="hobbies[]" value="Traveling"/>Traveling<br/>
<input type="checkbox" id="hobbies" name="hobbies[]" value="Baking"/>Baking<br/><br/>

<label>Gender</label><br><br>  <!-- drop donw list has been used to choose gender and locations -->
     <input type="radio" id="Gender" name="gender" value="Male" > Male<br>
    <input type="radio"
    </hr>
    <button type="submit" class="registerbtn" >Register</button>
    <button type="reset" class="Reset">Reset</button>   

</form>
Your Full Name : <?php echo $_GET["text1"]; ?><br/>
Your Email address : <?php echo $_GET["email"]; ?><br/>
Your Hobbies : <?php foreach($_GET['hobbies'] as $selected){
echo $selected.", ";};?><br/>
Your Gender : <?php echo $_GET["gender"]; ?><br/>
    Your Full Name : <?php echo $_POST["text1"]; ?><br/>
    Your Email address : <?php echo $_POST["email"]; ?><br/>
    Your Hobbies : <?php foreach($_POST['hobbies'] as $selected){
    echo $selected.", ";};?><br/>
    Your Gender : <?php echo $_POST["gender"]; ?><br/>
    window.location.href =
 URL?text1="+text1+"&email="+email+"&hobbies="+hobbies+"+&gender="+gender+"