Jump to content

If else in innerHTML code - help?


ryel01

Recommended Posts

Hello!

Can anyone show me how to property format the following code so it doesn't produce errors? What I'm trying to do is print the value assigned to "actualPrice" if it is over 0, otherwise print 0.

[code]
methodCell.innerHTML = '<input type="hidden" name="ShippingOptions[]" value="' + regionID + '|' + methodID + '|' + ( if (price > 0) { actualPrice } else { 0 } ) + '" />';
[/code]

Regan
Link to comment
https://forums.phpfreaks.com/topic/27150-if-else-in-innerhtml-code-help/
Share on other sites

I'm thinking:
[code]methodCell.innerHTML = '<input type="hidden" name="ShippingOptions[]" value="' + regionID + '|' + methodID + '|' + eval(parseFloat(price) > 0 ? parseFloat(actualPrice) : 0) + '" />'[/code]
I'm just assuming floating points are involved, actualPrice has been set as a string, and price is a form field value ???

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.