Jump to content

Help building an evaluation system


Prosjeik

Recommended Posts

Hi.

 

I'm going to create a web-based system in php.

 

I wanna put 8 categorys, one on each row and behind each of them there will be 9 buttons.- to the right there vill be a 8x9 cells table.

 

When i press one button the value of that buttons variable will increase with 1.

 

After pressing the button im still at the same page still seeing all those buttons behind the categories. But the value to the button i just pressed will be shown in the table to the right.

 

I may press several buttons a hundred times and the table still show the value (value = how many time i press each button).

 

Can anyone help me on my way? I did work a lot with php for about 10 years ago, but i cant figure out how this could be done..

Link to comment
Share on other sites

You need JavaScript for this.

 

<form action="" method="post">
  <input type="button" name="button1" value="1" class="increase-value">
</form>

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
  $('.increase-value').click(function() {
    var $this = $(this);
    $this.val(parseInt($this.val(), 10) + 1);
    alert($this.val());
  });
</script>
Link to comment
Share on other sites

Are you serious about having to click 72 buttons 100 times to give assessment scores of 100? And if you accidentally overshoot then go round again!

 

Why not text input or dropdowns? This code will give you dropdowns.

<?php
$categories = array(
        1 =>    'Category 1',
        2 =>    'Category 2',
        3 =>    'Category 3',
        4 =>    'Category 4',
        5 =>    'Category 5',
        6 =>    'Category 6',
        7 =>    'Category 7',
        8 =>    'Category 8'
        );
$criteria = array(
        1 =>    'Crit 1',    
        2 =>    'Crit 2',    
        3 =>    'Crit 3',    
        4 =>    'Crit 4',    
        5 =>    'Crit 5',    
        6 =>    'Crit 6',    
        7 =>    'Crit 7',    
        8 =>    'Crit 8',    
        9 =>    'Crit 9'    
        );
$tableHead = "<tr><th> </th><th>" . join('</th><th>', $criteria) . "</th></tr>\n";
$opts = '';
for($i=0; $i<=100; $i++) {
    $v = $i==0 ? '' : $i;
    $opts .= "<option value='$i'>$v</option>";
}
?>
<html>
<head>
<meta name="expires" content= "Sat, 4 Dec 2128 00:00:00 GMT">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta name="generator" content="PhpED Version 8.1 (Build 8115)">
<title>Form sample</title>
<meta name="author" content="Barand">
<meta name="creation-date" content="11/02/2013">
<style type="text/css">
    select {
        width: 50px;
        margin: 3px;
        border: none;
        background-color: #eee;
    }
    th {
        color: white;
        font-weight: 600;
        background-color: #369;
        padding: 2px 4px;
        width: 10%;
    }
    td {
        background-color: #eee;
        padding: 2px 4px;
    }
</style>
</head>
<body>

<h3>Assessment</h3>
<form method="post">
<table cellspacing="1">
    <?php 
        echo $tableHead; 
        foreach ($categories as $catid=>$cat) {
            echo "<tr><td>$cat</td>";
            foreach ($criteria as $cid=>$crit) {
                echo "<td><select name='assess[$catid][$cid]'>$opts</select></td>";
            }
            echo "</tr>\n";
        }
    ?> 
</table>
<input type="submit" name="btnSubmit" value="Submit">
</form>
</body>
</html>
Edited by Barand
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.