2013-01-04 33 views
0

我不確定它被稱爲什麼,但我真的想要一個表單,底部有兩個單選按鈕,表示您有客戶端是/否,如果他們點擊是,則表單的另一位出現。這裏是來自文件的代碼,它是PHP。添加更多內容的動態表單

<html> 
<body> 

<?php 
if (isset($_REQUEST['email'])) 
//if "email" is filled out, send email 
{ 
//send email 
$to = "email" ; 
$subject = "New Enquiry" ; 
$name = $_REQUEST['name'] ; 
$email = $_REQUEST['email'] ; 
$address = $_REQUEST['address'] ; 
$address2 = $_REQUEST['address2'] ; 
$postcode = $_REQUEST['postcode'] ; 
$city = $_REQUEST['city'] ; 
$tel = $_REQUEST['tel'] ; 
$tel2 = $_REQUEST['tel2'] ; 
$club = $_REQUEST['club'] ; 
$which = ", " . $_REQUEST['which'] ; 
$passdetails = $_REQUEST['updates'] ; 
$cname = $_REQUEST['cname'] ; 
$ctel = $_REQUEST['ctel'] ; 
$cloan = $_REQUEST['cloan'] ; 
$creasons = $_REQUEST['creasons'] ; 
$message = "Name: " . $name . "\n Email: " . $email . "\n Address: " . $address . ", " .  $address2 . "\n Postcode: " . $postcode . "\n City: " . $city . "\n Telephone Number: " . $tel . "\n Alternative Number: " . $tel2 . "\n Member of a club?: " . $club . $which . "\n Can use details: " . $passdetails . "\n" . "\n Client Details (Optional): " . "\n" . "\n Client Name: " . $cname . "\n Client Telephone Number: " . $ctel . "\n Loan Amount: " . $cloan . "\n Reasons for loan: " . $creasons ; 
$from = "Introducer Registration" ; 

mail($to,$subject,$message,"From: " . $from) ; 

echo "<p style='font-size:12px;font-family:helvetica;color:#000000;'>Thank you for using our enquiry form, a member of the team will contact you as soon as they can.</p>"; 
} 
else 
//if "email" is not filled out, display the form 
{ 
echo "<form action='register.php' method='post' style='width:21cm;font-family:helvetica;font-size:12px;'> 

<p style='font-size:12px;padding-bottom:3px;margin-bottom:3px;'><I>* = required</I></p> 
<label>Name*</label><label style='margin-left:353px;'>Email*</label><br /> 
<input type='text' style='width:10cm;padding-top:4px;' name='name' /> 
<input type='text' style='width:10cm;padding-top:4px;margin-left:10px;' name='email' /> 
<br /> 

<label>Address Line One*</label><label style='margin-left:289px;'>Address Line Two</label><br /> 
<input type='text' style='width:10cm;padding-top:4px;' name='address' /> 
<input type='text' style='width:10cm;padding-top:4px;margin-left:10px;' name='address2' /> 
<br /> 

<label>Town/City</label><label style='margin-left:338px;'>Postcode*</label><br /> 
<input type='text' style='width:10cm;padding-top:4px;margin-bottom:0px;' name='city' /> 
<input type='text' style='width:10cm;padding-top:4px;margin-left:10px;' name='postcode' /> 
<br /> 

<label>Phone Number*</label><label style='margin-left:304px;'>Alternative Number</label><br /> 
<input type='text' style='width:10cm;padding-top:4px;margin-bottom:0px;' name='tel' /> 
<input type='text' style='width:10cm;padding-top:4px;margin-left:10px;margin-bottom:0px;' name='tel2' /> 
<br /> 

<br /> 
<label style='margin-top:-10px;'>Are you a member of a club?*</label><label style='margin-left:231px;margin-top:-10px;'>If yes, which club?</label><br /> 
<input type='radio' name='club' value='Yes' style='margin-top:-10px;' /><span style='font-family:source sans pro;color:#000000;'>Yes</span> 
<input type='radio' name='club' value='No' /><span style='font-family:source sans pro;color:#000000;'>No</span> 
<input type='text' name='which' style='font-family:source sans pro;color:#000000;;width:10cm;margin-left:320px;margin-top:0px;' /> 
<br /> 
<br /> 
<input type='hidden' name='updates' value='Yes' /> 
<input type='checkbox' name='updates' value='No'/><label style='font-family:source sans pro;color:#000000;' value='updates'>*If you <u>DO NOT</u> wish to be contacted by affiliated companies with potentially helpful products and services, please tick this box.</label> 
<br /> 
<br /> 
<h9 style='font-size:14px;'>Enter Client Details for assessment <i>(optional)</i></h9> 
<br /> 
<br /> 
<label>Name</label><label style='margin-left:360px;'>Phone Number</label><br /> 
<input type='text' style='font-family:source sans pro;color:#000000;width:10cm;padding-top:4px;' name='cname' /> 
<input type='text' style='font-family:source sans pro;color:#000000;width:10cm;padding-top:4px;margin-left:10px;' name='ctel' /> 
<br /> 

<label>Loan Amount</label><label style='margin-left:319px;'>Reasons for loan</label><br /> 
<input type='text' style='font-family:source sans pro;color:#000000;width:10cm;padding-top:4px;' name='cloan' /> 
<input type='text' style='font-family:source sans pro;color:#000000;width:10cm;padding-top:4px;margin-left:10px;' name='creasons' /> 
<br /> 


<br /> 
<input style='margin-left:713px;padding:0;' type='submit' value='Submit' /> 

</form>"; 
} 
?> 

</body> 
</html> 

進行評估的「輸入客戶的詳細信息之前,我真的想擁有它,使他們可以選擇他們是否有他們,再一個形式,如果他們這樣做滴下來,但是這一切又通過電子郵件發送,我想,這樣他們在同一個電子郵件LL。

感謝您的幫助!

+0

[動態添加表單字段](http://www.mustbebuilt.co.uk/2012/07/27/adding-form-fields-dynamically-with-jquery/)這可能有幫助 – Kirtan

回答

0

放在一個DIV的「輸入評估客戶的詳細資料」部分,將CSS這個DIV是:

display:none 

這將隱藏它的視圖。

把一個onclick在「是」無線電元件,使得被選中時,一個JavaScript函數運行,將改變的div的風格:

display:inline 

這樣,你會希望添加另一個點擊'否'無線電元件,這樣如果選擇了那個元件,它將顯示回到隱藏狀態。