dongtuo0828 2014-01-04 00:44
浏览 30
已采纳

用PHP的Javascript表单发布

JS CODE:

    function yetiskintext() {

    document.getElementById("yetiskindiv").innerHTML="";
    var secenek=document.getElementById("yetiskinid").value;

    while (secenek>0){
    var newlabel = document.createElement("Label");
    newlabel.setAttribute("for","keke");
    newlabel.innerHTML = "Adı :";
    newlabel.className='selectTravelInputFieldsCarText';
    document.getElementById("yetiskindiv").appendChild(newlabel);   

    var textBoxname = document.createElement('input');
    textBoxname.name = 'textyetiskinname'+secenek;
    textBoxname.id='textyetiskinname'+secenek;
    textBoxname.type = 'text';
    textBoxname.className='selectTravelInputFieldsCar';
    document.getElementById("yetiskindiv").appendChild(textBoxname);

    var newlabel = document.createElement("Label");
    newlabel.setAttribute("for","keke");
    newlabel.innerHTML = "</br>";
    document.getElementById("yetiskindiv").appendChild(newlabel);

MAIN PHP PAGE:

<div id="yetiskindiv"></div>

FORM START:

<form method="post" name="sigortayap"  action="sigorta-process.php" onsubmit="return dene()" >

SIGORTA_PROCESS.PHP:

<?php

    $yetiskinsayisi=htmlspecialchars($_POST["yetiskin"]);

    $cocuksayisi=htmlspecialchars($_POST["cocuk"]);
    $e=1;
     $a=htmlspecialchars($_POST["textyetiskinname".$e]);
    print $a; 

    echo $yetiskinsayisi;
    echo $cocuksayisi;


?>

I want to post my form. My form keeping js page i get form in <div>. How can I post this form ?

  • 写回答

1条回答 默认 最新

  • duangouhui0446 2014-01-04 00:50
    关注

    You should have a submit button in your form to submit it:

    <input type="submit" value="Submit Form"/>
    

    Here's what i've understood after looking at your code:

    <form method="post" name="sigortayap"  action="sigorta-process.php" onsubmit="return dene()" >
    

    when you say, onsubmit="return dene()" and dene() returns false then the form wont submit, so make sure that the function doesn't false.

    If you want to do it via code:

    <form id="yourform" method="post" name="sigortayap"  action="sigorta-process.php" onsubmit="return dene()" >
    

    and in JS:

    yourform.submit()
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?