我想将值从第一个表单传递到另一个表单,但是当我只传递单个值时会打开页面,但是当我尝试传递多个值时,它不会打开页面。
只有一个值,它可以正常工作。
<script type="text/javascript">
$(document).ready(function() {
$("#div1").load("http://ppp.qwert.com/wp-content/themes/thestory/compare-form-site.php?loanamt=" + <?php echo $_POST['loanAmt']; ?>);
});
</script>
如果超过一个,则无法加载页面。我只收到我正在捕获的字符值的错误。喜欢未定义任何字符值的元素。我该如何解决这个错误。
$("#div1").load("http://ppp.qwert.com/wp-content/themes/thestory/compare-form-site.php?loanamt="+<?php echo $_POST['loanAmt'];?>+"&occupation="+<?php echo $_POST['occupation']; ?>+"&rateType="+<?php echo $_POST['rateType']; ?>+"&age="+<?php echo $_POST['age']; ?>+"&city="+<?php echo $_POST['city']; ?> );
这是我的HTML代码
<div id="dynamicform" class="dynamicform">
<div class="formDiv" id="offeringTypeIdDiv_31">
<form name="offeringTypeIdForm_31" id="offeringTypeIdForm_31" action="http://ppp.qwerty.com/16708-2?q=gold+loan" method="post" >
<input type="hidden" name="offeringTypeId" value="31">
<input type="hidden" name="q" value="gold+loan">
<div class="fStep1" id="fStep1">
<input type="hidden" value="15" name="product_id"/>
<h3>Compare Gold Loan Offers</h3>
<div class="form-main">
<label class="formLabel">Purpose</label>
<select id="purpose" class="inputwraprer" tabindex="0" style="width: 100%; height: 39px;">
<option value="">Purpose</option>
<option value="Gold Loan" selected="selected">Gold Loan</option>
</select>
</div>
<div class="form-main">
<label class="formLabel">Loan Amount</label>
<input type="text" name="loanAmt" id="loanAmt" value="" class="inputwraprer" required tabindex="1" autocomplete="off" placeholder="Enter Loan Amount" />
</div>
</div>
<div style="clear:both;"></div>
<div class="fStep2" id="fStep2">
<div class="form-main">
<label class="formLabel">Occupation</label>
<select name="occupation" class="inputwraprer" required tabindex="2" style="width: 100%; height: 39px;">
<option value="">Occupation</option>
<option value="Salaried"
>Salaried</option>
<option value="self+Employed"
>Self Employed</option>
</select>
</div>
<div style="clear:both"></div>
<div class="form-main">
<label class="formLabel">Interest Type</label>
<span class="putradio">
<input class="radioButton required" type="radio" id="fixed" value="Fixed" name="rateType" tabindex="3" />
Fixed</span> <span class="putradio">
<input class="radioButton" type="radio" id="floating" value="Floating" name="rateType" tabindex="4" />
Floating</span> <span class="putradio">
<input class="radioButton" type="radio" id="both" value="Both" name="rateType" tabindex="5" />
Both</span> </div>
<div style="clear:both"></div>
<div class="form-main">
<label class="formLabel">Age</label>
<select id="age" class="inputwraprer" required tabindex="6" name="age" style="width: 100%; height: 39px;">
<option value="">Age</option>
<option value="18"
>18 Years</option>
<option value="19"
>19 Years</option>
<option value="20"
>20 Years</option>
<option value="21"
>21 Years</option>
<option value="22"
>22 Years</option>
<option value="23"
>23 Years</option>
<option value="24"
>24 Years</option>
<option value="25"
>25 Years</option>
</select>
</div>
<div style="clear:both"></div>
<div class="form-main" id="cityDiv">
<label id="cityLabel" class="formLabel">City</label>
<input type="hidden" id="cityTextBox" name="cityTextBox" />
<select id="city" name="city" class="inputwraprer" placeholder="Enter a city" style="width: 100%; height: 39px;" required tabindex="7">
<option value="" selected="selected">Select a city</option>
<option value="9">Bangalore</option>
<option value="20">Chennai</option>
<option value="27">Faridabad</option>
<option value="28">Ghaziabad</option>
<option value="32">Gurgaon</option>
<option value="36">Howrah</option>
<option value="38">Hyderabad</option>
<option value="49">Kolkata</option>
<option value="57">Mumbai</option>
</select>
</div>
</div>
<div style="clear:both"></div>
<div class=" form-main" style="text-align: center;margin: 10px 0 15px;">
<input type="submit" name="submitForm" value="Compare" class="submitButton" id="submitForm">
</div>
</form>
</div>
</div>
答案 0 :(得分:1)
你最后忘记了结束双引号"
,也不需要连续的双打,你必须直接回复你的php。
如果您使用的是javascript变量,则只使用concat
从
改变 $("#div1").load("http://ppp.qwert.com/wp-content/themes/thestory/compare-form-site.php?loanamt="+<?php echo $_POST['loanAmt'];?>+"&occupation="+<?php echo $_POST['occupation']; ?>+"&rateType="+<?php echo $_POST['rateType']; ?>+"&age="+<?php echo $_POST['age']; ?>+"&city="+<?php echo $_POST['city']; ?> );
到
$("#div1").load("http://ppp.qwert.com/wp-content/themes/thestory/compare-form-site.php?loanamt=<?php echo $_POST['loanAmt'];?>&occupation=<?php echo $_POST['occupation']; ?>&rateType=<?php echo $_POST['rateType']; ?>&age=<?php echo $_POST['age']; ?>&city=<?php echo $_POST['city']; ?>" );
这样你就像这样做
$("#div1").load("http://ppp.qwert.com/wp-content/themes/thestory/compare-form-site.php?loanamt=value&occupation=value&rateType=value&age=value&city=value" );
答案 1 :(得分:0)
尝试引用PHP代码
<script type="text/javascript">
$(document).ready(function() {
$("#div1").load("http://ppp.qwert.com/wp-content/themes/thestory/compare-form-site.php?loanamt=" + '<?php echo $_POST['loanAmt']; ?>');
});
</script>