Warrior Forum - The #1 Digital Marketing Forum & Marketplace

Warrior Forum - The #1 Digital Marketing Forum & Marketplace (https://www.warriorforum.com/)
-   Programming (https://www.warriorforum.com/programming/)
-   -   PHP Tutorial (https://www.warriorforum.com/programming/812818-php-tutorial.html)

pvijeh 11th July 2013 01:40 AM

PHP Tutorial
 
Can any one suggest a tutorial that would teach me to build something like this "bottle service price calculator"

https://www.ezvip.com/events/36025/#tables-estimate

Looks pretty simple, but I don't know any PHP


Thanks

Peter

phpg 11th July 2013 06:54 AM

Re: PHP Tutorial
 
You don't need php for this, it's javascript.

Brandon Tanner 11th July 2013 09:33 AM

Re: PHP Tutorial
 
Looks like they are using jQuery AND PHP for that particular calculator. If you look at that page's source code, then scroll about half way down it -- you'll see a bunch of <option> tags and then jQuery code below it. One of the jQuery lines calls a PHP file (orderprocess.php) and extracts data from it.

But phpg is correct that you don't need to use PHP to create a calculator like this. You can do it in pure Javascript / jQuery.

Here's a quick example how something like that could be accomplished using jQuery (assuming that you want the cost for each person to be $100)...

HTML Code:

<!DOCTYPE html>
<html>
<head>
    <script src="http://code.jquery.com/jquery-1.9.0.min.js"></script>
</head>

<body>

<label>Guys</label>
<select id="guys" class="people">
    <option value="0" selected>0</option>
    <option value="1">1</option>
    <option value="2">2</option>
    <option value="3">3</option>
</select>

<label>Girls</label>
<select id="girls" class="people">
    <option value="0" selected>0</option>
    <option value="1">1</option>
    <option value="2">2</option>
    <option value="3">3</option>
</select>

<label>Total Cost</label>
<input type="text" id="cost" value="$0">

<script>
$('.people').change(function() {
    var quantity = $('#guys').val() * 1 + $('#girls').val() * 1;
    var price = "$" + quantity * 100;
    $('#cost').val(price);
});
</script>

</body>
</html>


pvijeh 11th July 2013 01:51 PM

Re: PHP Tutorial
 
thanks! very helpful

rypher21 12th July 2013 01:15 AM

Re: PHP Tutorial
 
Try to visit W3Schools Online Web Tutorials . It has many useful information and tutorials mostly about web development (HTML,PHP, CSS etc. )


All times are GMT -6. The time now is 12:21 PM.