0

ユーザーが「何かを持っている」場合に「はい」を選択するフォームを作成しました。投稿アクションを持つフォーム内で使用しており、値が .php ファイルに送信されます。ボタンを使用してチェックしようとするif (isset($_POST['agentsele']))と、読み戻されません。テストする印刷ステートメントがいくつかありますが、実行されません。入力フィールドをボタンからチェックボックスに変えて、それを読んでみました-うまくいきました。私がそれを元に戻した後、行きません。

ここに入力フィールドがあります。

<input type="button"  value="Yes" name="agentsele" class="agentsele"/>

チェック方法。

if (isset($_POST['agentsele'])) {

                $emailaction = 1;//email agent and set status to - enrolled - agent emailed
                echo "agent selected";
                exit;
            }

また、ボタンが選択された場合に、より多くの入力ボックスを下にスライドさせる JQuery もあります。

お時間をいただきありがとうございます。

更新 -------------------- フォーム全体

<form name="theform" action="insert.php" method="post" >
                <div class="CheckBoxContainer">
            <input type="checkbox" value"On" name="only-thisform"/>
            <?php 
            $setError=$_GET['seterror'];

            if ($setError == 1){

                echo "<div class='errorMsg'> *Required</div>";
            }
             ?>
            <br>
            <br>

            <input type="checkbox"  value="On" name="approval" id="approval"/>
             <?php 
             $setError=$_GET['seterror'];
             if ($setError == 1){

                echo "<div class='errorMsg'> *Required</div>";
             }

             ?>
            </div><!------------------------------------END   .CheckBoxContainer ------------------------------------------->
            <br>
            <br>


<script type="text/javascript"
     src="http://code.jquery.com/jquery-latest.min.js">
</script>   
<!-- javascript on client-side -->


<div class="DropDownSelector">
<?php

$dropdown = "<select name='CompanyNames' id='CompanyNames' >";

$dropdown .= "\r\n<option  id ='' name ='' value='' class=''  ></option>";

$dropdown .= "\r\n<option  id ='other' name ='other' value='other' class='other'  >other</option>";

while($row =$FNresult->fetch()) {

  $dropdown .= "\r\n<option  id ='firstname' name ='first' value='{$row['CompanyNames']}'>{$row['CompanyNames']}</option>";
}

$dropdown .= "\r\n</select>";

echo $dropdown;
?>
    <div class="DropdownDiscription">Please select your insurance company.  Select other if you do not see it listed. </div>
</div> <!------------------------------------------END .DropDownSelector -------------------------------------------------------->
<script type="text/javascript">  

var dropdown = $('#CompanyNames');
//var test = $('#firstname');
//document.write(dropdown.val());

dropdown.bind('change', function(){

     if(dropdown.val() == "other"){
        $(".otherbox").slideDown(1000,function(){
           // $(this).css("border", "2px red inset")            
        });  
         $(".InputDiscriptionother").slideDown(1000,function(){
           // $(this).css("border", "2px red inset")            
        });          
    }else{
          $(".otherbox").slideUp(1000); 
           $(".InputDiscriptionother").slideUp(1000);   
    }

    $.post('backgroundScript.php', 
        { 
            'CompanyNames': dropdown.val()

        },
        function(response) {
            $('#compname').val(response.Companyname);
            //$('#phone').val(response.phone);
            //$('#policynum').val(response.policynum);
            //$('#nameofPolicyholder').val(response.policyholder);
            //$('#mailing').val(response.mailing);
            // Repeat for all of your form fields
        },
        'json'
    );

});
</script>
<br>


<!--<input type="text" class="otherbox" />
<input type="text" class="otherbox" />

<input type="text" class="otherbox"/>-->

<div class="FormBody">

    <div class="InputContainer">
<span class="InputDiscriptionother">Insurance Company Name: </span><div class="InputInner"> <input type="text" name="compname" id="compname" class="otherbox" ></div><!----- END .InputInner ---------->

<?php
 $setError=$_GET['seterror']; 
if($setError == 1){
    echo "<span class='errorMsg'>*Required</span>";
    }
else
    //echo "<span>*</span>"; 
?>

</div><!---------------------------------END .InputContaienr ----------------------------------->
<br>
    <div class="InputContainer">
<span class="InputDiscription">Insurance Phone number: </span><div class="InputInner"><input type="text"  name="phone" id="phone" ></div><!----- END .InputInner ---------->
<?php
 $setError=$_GET['seterror']; 
if($setError == 1){
    echo "<span class='errorMsg'>*Required</span>";
    }
else
    //echo "<span>*</span>"; 
?>

</div><!---------------------------------END .InputContaienr ----------------------------------->
<br>
<div class="InputContainer">
     <div class="agensele"> Do you have an agent? <input type="button"  value="Yes" name="agentsele" class="agentsele"/></div><!----- END .InputInner ---------->
     <?php
 $setError=$_GET['seterror']; 
if($setError == 1){
    echo "<span class='errorMsg'>*Required only if selected</span>";
    }
else
    //echo "<span>*</span>"; 
?>
     <div class="noagensele"> Do you have an agent? <input type="button"  value="No" name="noagentsele" class="noagentsele"/> </div><!----- END .InputInner ---------->
</div><!---------------------------------END .InputContaienr ----------------------------------->
<br>
<div class="InputContainer">
<span class="agent">Agent Name: </span><div class="InputInner"> <input type="text" name="agentname"  class="agentinput" ></div><!----- END .InputInner ---------->



</div><!---------------------------------END .InputContaienr ----------------------------------->

<div class="InputContainer">
<span class="agent">Agent Phone Number: </span><div class="InputInner"> <input type="text" name="agentphone"  class="agentinput" ></div><!----- END .InputInner ---------->



</div><!---------------------------------END .InputContaienr ----------------------------------->
<div class="InputContainer">
<span class="agent">Agent's Email: </span><div class="InputInner"> <input type="text" name="agentemail"  class="agentinput" ></div><!----- END .InputInner ---------->



</div><!---------------------------------END .InputContaienr ----------------------------------->
<div class="InputContainer">
<span class="agent">Confirm Agent's Email: </span><div class="InputInner"> <input type="text" name="agentemailone"  class="agentinput" ></div><!----- END .InputInner ---------->



</div><!---------------------------------END .InputContaienr ----------------------------------->
<script>
$(".agentsele").click(function () {
    $(this).css({ borderStyle:"inset", cursor:"wait" });
    //dropdown.bind('change', function(){   
    $(".agentinput").slideDown(1000,function(){
    });
    $(".agent").slideDown(1000,function(){
    });
    //$(".agentsele").css("visibility", "hidden");
    //$(".agensele").css("visibility", "hidden");
    $(".noagentsele").css("visibility", "visible");
    $(".noagensele").css("visibility", "visible");
});
$(".noagentsele").click(function () {
    $(this).css({ borderStyle:"inset", cursor:"wait" });
    //dropdown.bind('change', function(){   
    $(".agentinput").slideUp(1000,function(){
    });
    $(".agent").slideUp(1000,function(){
    });
    $(".agentsele").css("visibility", "visible");
    $(".agensele").css("visibility", "visible");
    $(".noagentsele").css("visibility", "hidden");
    $(".noagensele").css("visibility", "hidden");
});

</script>

<br>
    <div class="InputContainer">
    <span class="InputDiscription">Name of the Policyholder: </span><div class="InputInner"><input type="text" name="nameofPolicyholder" id="nameofPolicyholder"></div><!----- END .InputInner ---------->
<?php
 $setError=$_GET['seterror']; 
if($setError == 1){
    echo "<span class='errorMsg'>*Required</span>";
    }
else
    //echo "<span>*</span>"; 
?>

</div><!---------------------------------END .InputContaienr ----------------------------------->
<br>
<div class="InputContainer">
     <div class="InputInner"> Not the Policy Holder? <input type="checkbox"  value="On" name="notpolicyholder" class="notpolicyholder"/></div><!----- END .InputInner ---------->
</div><!---------------------------------END .InputContaienr ----------------------------------->

<br>
    <div class="InputContainer">
<span class="InputDiscription">Policy Number: </span><div class="InputInner"><input type="text" name ="policynum" id="policynum" ></div><!----- END .InputInner ---------->
<?php
 $setError=$_GET['seterror']; 
if($setError == 1){
    echo "<span class='errorMsg'>*Required</span>";
    }
else
    //echo "<span>*</span>"; 
?>


</div><!---------------------------------END .InputContaienr ----------------------------------->
<br>
    <div class="InputContainer">
<span class="InputDiscription">Policyholder mailing address: </span><div class="InputInner"><input type="text" name="mailing" id="mailing"></div><!----- END .InputInner ---------->
<?php
 $setError=$_GET['seterror']; 
if($setError == 1){
    echo "<span class='errorMsg'>*Required</span>";
    }
else
    //echo "<span>*</span>"; 
?>

</div><!---------------------------------END .InputContaienr ----------------------------------->
<br>
    <div class="InputContainer">
<span class="InputDiscription">City: </span><div class="InputInner"><input type="text" name="city" id="city"></div><!----- END .InputInner ---------->
<?php
 $setError=$_GET['seterror']; 
if($setError == 1){
    echo "<span class='errorMsg'>*Required</span>";
    }
else
    //echo "<span>*</span>"; 
?>


</div><!---------------------------------END .InputContaienr ----------------------------------->
<br>
    <div class="InputContainer">
    <!------------------------------------------STATE SELECTION CODE ------------------------------------------->
<?php
    function state_select ($name,$full_state,$selected = '') {

  $state_list = array("AL|Alabama","AK|Alaska","AZ|Arizona", "AR|Arkansas", "CA|California", "CO|Colorado", "CT|Connecticut", "DE|Delaware", "DC|Washington D.C.", "FL|Florida", "GA|Georgia", "HI|Hawaii", "ID|Idaho", "IL|Illinois", "IN|Indiana", "IA|Iowa", "KS|Kansas", "KY|Kentucky", "LA|Louisiana", "ME|Maine", "MD|Maryland", "MA|Massachusetts", "MI|Michigan", "MN|Minnesota", "MS|Mississippi", "MO|Missouri", "MT|Montana", "NE|Nebraska", "NV|Nevada", "NH|New Hampshire", "NJ|New Jersey", "NM|New Mexico", "NY|New York", "NC|North Carolina", "ND|North Dakota", "OH|Ohio", "OK|Oklahoma", "OR|Oregon", "PA|Pennsylvania", "RI|Rhode Island", "SC|South Carolina", "SD|South Dakota", "TN|Tennessee", "TX|Texas", "UT|Utah", "VT|Vermont", "VA|Virginia", "WA|Washington", "WV|West Virginia", "WI|Wisconsin", "WY|Wyoming");

  ?>
  <select name=<?=$name;?> id="state" onChange="submitform()"><?
    foreach ($state_list as $s) {
        $values = explode("|",$s);
        ?><option value="<?=$values[0];?>" <?
                if($selected == $values[0]) { ?>SELECTED<? }
                ?>>

                <?  if($full_state) { ?><?=$values[1];?><? } else { ?><?=$values[0];?><? } ?></option><?
    }
  ?></select><?
}
?>

<span class="InputDiscription">State: </span><div class="InputInner">
<?=state_select('state',false,'AL'); ?>
<input type="hidden" id="hiddenfield" name="hiddenfield" value="">
 </div><!----- END .InputInner ---------->

<?php

 $setError=$_GET['seterror']; 
if($setError == 1){
    echo "<span class='errorMsg'>*Required</span>";
    }
else
    //echo "<span>*</span>"; 

?>

</div><!---------------------------------END .InputContaienr ----------------------------------->
<br>
<div class="InputContainer">
<span class="InputDiscription">Zipcode: </span><div class="InputInner"><input type="text" name="zipcode" id="zipcode"></div><!----- END .InputInner ---------->
<?php
 $setError=$_GET['seterror']; 
if($setError == 1){
    echo "<span class='errorMsg'>*Required</span>";
    }
else
    //echo "<span>*</span>"; 
?>


</div><!---------------------------------END .InputContaienr ----------------------------------->
<br>
<br>
<div class="InputContainer">
<span class="InputDiscription">Year Of Vehicle: </span><div class="InputInner"><input type="text" name="YearOfVehicle" id="YearOfVehicle"></div><!----- END .InputInner ---------->
<?php
 $setError=$_GET['seterror']; 
if($setError == 1){
    echo "<span class='errorMsg'>*Required</span>";
    }
else
    //echo "<span>*</span>"; 
?>


</div><!---------------------------------END .InputContaienr ----------------------------------->
<br>
<div class="InputContainer">
<span class="InputDiscription">Make Of Vehicle: </span><div class="InputInner"><input type="text" name="MakeOfVehicle" id="MakeOfVehicle"></div><!----- END .InputInner ---------->
<?php
 $setError=$_GET['seterror']; 
if($setError == 1){
    echo "<span class='errorMsg'>*Required</span>";
    }
else
    //echo "<span>*</span>"; 
?>


</div><!---------------------------------END .InputContaienr ----------------------------------->
<br>
<div class="InputContainer">
<span class="InputDiscription">Model Of Vehicle: </span><div class="InputInner"><input type="text" name="ModelOfVehicle" id="ModelOfVehicle"></div><!----- END .InputInner ---------->
<?php
 $setError=$_GET['seterror']; 
if($setError == 1){
    echo "<span class='errorMsg'>*Required</span>";
    }
else
    //echo "<span>*</span>"; 
?>


</div><!---------------------------------END .InputContaienr ----------------------------------->
<br>
<div class="InputContainer">
<span class="InputDiscription">Vehicle Identification Number: </span><div class="InputInner"><input type="text" name="Vehicleid" id="Vehicleid"></div><!----- END .InputInner ---------->
<?php
 $setError=$_GET['seterror']; 
if($setError == 1){
    echo "<span class='errorMsg'>*Required</span>";
    }
else
    //echo "<span>*</span>"; 
?>


</div><!---------------------------------END .InputContaienr ----------------------------------->
<br>
<div class="InputContainer">
<span class="InputDiscription">Policy Effective Date: </span><div class="InputInner"><input type="text" name="Policyeffdate" id="Policyeffdate"></div><!----- END .InputInner ---------->
<?php
 $setError=$_GET['seterror']; 
if($setError == 1){
    echo "<span class='errorMsg'>*Required</span>";
    }
else
    //echo "<span>*</span>"; 
?>


</div><!---------------------------------END .InputContaienr ----------------------------------->
<br>
<div class="InputContainer">
<span class="InputDiscription">Policy Expiration Date: </span><div class="InputInner"><input type="text" name="Policyexpdate" id="Policyexpdate"></div><!----- END .InputInner ---------->
<?php
 $setError=$_GET['seterror']; 
if($setError == 1){
    echo "<span class='errorMsg'>*Required</span>";
    }
else
    //echo "<span>*</span>"; 
?>


</div><!---------------------------------END .InputContaienr ----------------------------------->
<br>
<br>
<h2>Employee Information</h2>

<div class="InputContainer">
<span class="InputDiscription">Employee Name: </span><div class="InputInner"><input type="text" name="EmployeeName" id="EmployeeName"></div><!----- END .InputInner ---------->
<?php
 $setError=$_GET['seterror']; 
if($setError == 1){
    echo "<span class='errorMsg'>*Required</span>";
    }
else
    //echo "<span>*</span>"; 
?>


</div><!---------------------------------END .InputContaienr ----------------------------------->
<br>
<br>
<div class="InputContainer">
<span class="InputDiscription">Employee Company Name: </span><div class="InputInner"><input type="text" name="EmployeeCompanyName" id="EmployeeCompanyName"></div><!----- END .InputInner ---------->
<?php
 $setError=$_GET['seterror']; 
if($setError == 1){
    echo "<span class='errorMsg'>*Required</span>";
    }
else
    //echo "<span>*</span>"; 
?>


</div><!---------------------------------END .InputContaienr ----------------------------------->
<br>
<div class="InputContainer">
<span class="InputDiscription">Agency/Franchise Number (or unique indicator): </span><div class="InputInner"><input type="text" name="Agency/FranchiseNumber" id="Agency/FranchiseNumber"></div><!----- END .InputInner ---------->
<?php
 $setError=$_GET['seterror']; 
if($setError == 1){
    echo "<span class='errorMsg'>*Required</span>";
    }
else
    //echo "<span>*</span>"; 
?>


</div><!---------------------------------END .InputContaienr ----------------------------------->
<br>
<div class="InputContainer">
<span class="InputDiscription">Todays Date: </span><div class="InputInner"><input type="text" name="TodaysDate" id="TodaysDate" value="
<?php

$today = date("n-j-Y"); 
echo $today;
?>">
</div><!----- END .InputInner ---------->
<?php
 $setError=$_GET['seterror']; 
if($setError == 1){
    echo "<span class='errorMsg'>*Required</span>";
    }
else
    //echo "<span>*</span>"; 
?>


</div><!---------------------------------END .InputContaienr ----------------------------------->
<br>
<div class="CheckBoxContainer">
            <input type="checkbox" value"On" name="correct"/>The above printed name serves to identify the employee and shows intent of the employee that the above auto insurance information given is accurate.  
            <?php 
            $setError=$_GET['seterror'];

            if ($setError == 1){

                echo "<div class='errorMsg'> *Required</div>";
            }
             ?>
            <br>
            <br>

            <input type="checkbox"  value="On" name="agree" id="agree"/>The employee identified above confirms this document has been read, reviewed and understood and subsequently authorizes it as such. 
             <?php 
             $setError=$_GET['seterror'];
             if ($setError == 1){

                echo "<div class='errorMsg'> *Required</div>";
             }

             ?>
             <br>
             <br>
             <input type="checkbox"  value="On" name="understood" id="understood"/>The employee understands that if inaccurate information is discovered on the above auto insurance information table, on the employee's auto policy itself or if the auto insurance policy is cancelled for any reason, the employer will be notified. 
             <?php 
             $setError=$_GET['seterror'];
             if ($setError == 1){

                echo "<div class='errorMsg'> *Required</div>";
             }

             ?>
            </div><!------------------------------------END   .CheckBoxContainer ------------------------------------------->
            <br>
<?php 
 $setError=$_GET['seterror']; 
if($setError == 1){
echo "<script type='text/javascript'>alert('Please check to make sure all required fields are filled out!');</script>";
}
?>


<input type="Submit" name="Submit" >

</div><!-------------------------------------------END .FormBody ------------------------------------------------------->
</form>

更新しました - - - - - - - - - -

タイプを送信に変更すると機能しましたが、データを挿入する関数に直接送信したくありません。送信を停止するにはどうすればよいですか。

4

4 に答える 4

4

フォームの送信でボタンの値が送信されない

于 2012-08-21T19:38:50.263 に答える
1

ボタンにフォーム データを含めることはできません。代わりに送信を使用してください

于 2012-08-21T19:39:14.493 に答える
0

フォームに「入力」タイプを非表示にすることができ、jQuery を使用してボタンにイベントを追加できます。

于 2012-08-21T19:54:33.660 に答える