dfowler Posted December 12, 2007 Share Posted December 12, 2007 Hey guys, I'll get right down to it. Here is the code: function refreshPrice() { var selectedradio; for (i=0;i<document.getElementById('appform').elements.length;i++) { ele = document.getElementById('appform').elements[i]; if (ele.type == 'radio' && ele.name == 'coverage' && ele.checked) { selectedradio = ele; break; } } price = (document.getElementById('equipment').checked ? 225 : 0) + (document.getElementById('technical').checked ? 0 : 0) + (document.getElementById('personal').checked ? 48 : 0) + pricekeys[selectedradio.value]; document.getElementById('totalprice').innerHTML = '$'+price.toString(); } I need the equipment(225), technical(0), and personal(48) to be modified depending on what their value is in a database. Anybody know how to do this? Quote Link to comment Share on other sites More sharing options...
nogray Posted December 12, 2007 Share Posted December 12, 2007 In your php file price = (document.getElementById('equipment').checked ? <?PHP echo $EquipValue;?> : 0) + (document.getElementById('technical').checked ? <?PHP echo $TechValue;?> : 0) + (document.getElementById('personal').checked ? <?PHP echo $PersValue;?> : 0) + pricekeys[selectedradio.value]; given the $EquipValue, $TechValue and $PersValue is the value from your db. Quote Link to comment Share on other sites More sharing options...
dfowler Posted December 14, 2007 Author Share Posted December 14, 2007 will this work even if this is from an external javascript document? Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted December 14, 2007 Share Posted December 14, 2007 You can include your "price" variable in your PHP page and then link to your External JavaScript or you can convert you JS file to a PHP file and set the header to be a JavaScript file; then link it like you would any other external JS file - except your script extension would no longer be "js"; it would be "php". It's up to you how you want to do it; the first way, I mentioned, is probably the easiest way. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.