尝试使用三元运算符进行简单的html更改。页面加载很好,html中唯一缺少的是#np_msg元素。不知道这里有什么问题。这是
的代码段form.js.php
var toprighttext = <?php echo ($company_id==69) ? 'Please add an organization.' : 'Please add nonprofit.'; ?>
jQuery('#np_msg').html(toprighttext).show();
出现的HTML
<div class="donationrequestformRight">
<div class="donationrequestinputWrap clearfix">
<label class="donationrequestlabel" for="donationrequest_nonprofit">
Your Organization
<span>*</span>
</label>
<input type="text" class="donationrequestinputbox correct" name="general[np_name]" id="donationrequest_nonprofit" value="">
<input type="hidden" name="general[np_id]" id="np_id" value="0" style="display:block;">
<div id="np_msg" style="display: none;"></div>
<p style="float: right;font-size: 14px;font-weight: bold;">Can't find your organization? <a href="javascript:void(0);" id="addNP">Add it here</a>.</p>
</div>
<div class="donationrequestinputWrap last clearfix">
<input type="hidden" name="drop_np_contact_id" id="drop_np_contact_id" value="0">
<input type="hidden" name="general[np_contact_id]" id="np_contact_id_final" value="0">
<label class="donationrequestlabel" for="donationrequest_contact">
Contact Information
<span>*</span></label>
<div id="contact_div">
</div>
<div id="np_con_load" style="float: right;"></div>
<p style="float: left;font-size: 13px;font-weight: normal;">
Click <a href="javascript:void(0);" id="addNPContact">here</a>
to add your contact information.
</p>
<div id="contact_msg" style="display: none;"></div>
</div>
<div class="darkgreybox clearfix" id="details_info" style="display: none;"></div>
</div>
答案 0 :(得分:1)
add quotes
var toprighttext = "<?php echo ($company_id==69) ? 'Please add an organization.' : 'Please add nonprofit.'; ?>";
jQuery('#np_msg').html(toprighttext).show();