只需执行一个简单的代码即可在我的PayPal按钮上应用促销代码。我刚刚在下面做了,但validate()函数没有警告。
我希望所有代码都正确无误。请检查小提琴,并让我知道为什么功能不起作用。
function validate( text1, text2 ) {
if ( text1 == text2 ) {
window.alert( "Nice, you get a 10% Discount!" );
}
if ( text1 !== text2 ) {
window.alert( "Sorry, No Discount!" );
}
}
function CalculateOrder( form ) {
if ( form.text1.value == "GOLD10" ) {
form.discount_rate.value = "10";
form.discount_rate2.value = "10";
form.on3.value = "Coupon Entered";
form.os3.value = "GOLD10";
}
}
<form target="_self" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart"/>
<input type="hidden" name="add" value="1"/>
<input type="hidden" name="business" value="fanciedmedia@gmail.com"/>
<input type="hidden" name="item_name" value="Blue Kidsport Burst"/>
<input type="hidden" name="amount" value="149.00"/>
<input type="hidden" name="currency_code" value="USD"/>
<input type="hidden" name="no_shipping" value="2">
<input type="hidden" name="weight_unit" value="lbs">
<input type="hidden" name="baseamt" value="149.00"/>
<input type="hidden" name="item_number" value="BUONBL">
<span id="dist"></span>
<input type="text" name="text1">
<input type="button" value="Check It" name="Submit" onclick=javascript:validate(text1.value, "GOLD10")>
<br>
<input name="submit" type="image" alt="Add to Cart" src="add_to.png" onclick=CalculateOrder(this.form)/>
</form>
答案 0 :(得分:0)
您错过了在@Override
public Object run() {
RequestContext ctx = RequestContext.getCurrentContext();
try {
InputStream is = ctx.getResponseDataStream();
String responseBody = IOUtils.toString(is);
if (StringUtils.hasText(responseBody)
&& responseBody.contains("access_token")) {
Map<String, Object> responseMap = objectMapper.readValue(
responseBody, new TypeReference<Map<String, Object>>() {});
String accesToken = responseMap.get("access_token").toString();
Jwt jwt = JwtHelper.decodeAndVerify(accesToken, new MacSigner(serviceConfig.getJwtSigningKey()));
System.out.println(jwt.getClaims());
//System.out.println(jwt.getBody());
}
ctx.setResponseBody(responseBody);
} catch (Exception e) {
logger.error("Error occured in zuul post filter", e);
}
return null;
}
属性中添加简单引号'
,您应该引用表单对象以获取onclick
值:
text1
应该是:
onclick=javascript:validate(text1.value, "GOLD10")
^^ ^^^ ^^
onclick=CalculateOrder(this.form)
^^ ^^
试试这段代码:
onclick='javascript:validate(form.text1.value, "GOLD10")'
onclick='CalculateOrder(this.form)'
function validate( text1, text2 ) {
if ( text1 == text2 ) {
window.alert( "Nice, you get a 10% Discount!" );
}
if ( text1 !== text2 ) {
window.alert( "Sorry, No Discount!" );
}
}
function CalculateOrder( form ) {
if ( form.text1.value == "GOLD10" ) {
form.discount_rate.value = "10";
form.discount_rate2.value = "10";
form.on3.value = "Coupon Entered";
form.os3.value = "GOLD10";
}
alert('submitting form');
form.submit();
}