0
<html>

<head>
    <script type="text/javascript">
function tally()
{
    var scrt_var = 10;


    var Dpoint, Ipoint, Hpoint, Apoint;
    var party_Score = ['Dpoint', 'Ipoint', 'Hpoint', 'Apoint'];
    var D, I, H, A;
    var value_Point;
    var type_Choice;
    var tag_Choice;


    var inputs = document.getElementsByTagName("input"),
        iLength = inputs.length,
    D = I = H = A = 0;

    for (i = 0; i < iLength; i++) if (inputs[i].checked)
    {
        value_Point = parseInt(inputs[i].value);
        if (inputs[i].name.search('D') > -1){ D += value_Point; }
        if (inputs[i].name.search('I') > -1){ I += value_Point; }
        if (inputs[i].name.search('H') > -1){ H += value_Point; }
        if (inputs[i].name.search('A') > -1){ A += value_Point; }
    }   //check here !!!~
Dpoint = D; // converting this to php data so i can send it by email
Ipoint = I; // converting this to php data so i can send it by email
Hpoint = H; // converting this to php data so i can send it by email
Apoint = A; // converting this to php data so i can send it by email


 document.addEventListener("DOMContentLoaded", function(event) {
    document.getElementById('D').style.width = D + 'px';
    document.getElementById('I').style.width = I + 'px';
    document.getElementById('H').style.width = H + 'px';
    document.getElementById('A').style.width = A + 'px';
  });

location.href = "test3.html?D="+ Dpoint + "&I=" + Ipoint + "&H=" + Hpoint + "&A=" + Apoint;


}
// ]]>
</script>
</head> 

<form method="post" action="data.php">
<table>
<tr>
<td>question1</td>
<td><input type="radio" name="D1" value="1"> 1 </td>
<td><input type="radio" name="D1" value="2"> 2 </td>
<td><input type="radio" name="D1" value="3"> 3 </td>
<td><input type="radio" name="D1" value="4"> 4 </td>
<td><input type="radio" name="D1" value="5"> 5 </td>
<td><input type="radio" name="D1" value="6"> 6 </td>
<td><input type="radio" name="D1" value="7"> 7 </td>
<td><input type="radio" name="D1" value="8"> 8 </td>
<td><input type="radio" name="D1" value="9"> 9 </td>
<td><input type="radio" name="D1" value="10"> 10 </td>              
</tr>
<tr>
<td>question2</td>
<td><input type="radio" name="I1" value="1"> 1 </td>
                <td><input type="radio" name="I1" value="2"> 2 </td>
                <td><input type="radio" name="I1" value="3"> 3 </td>
                <td><input type="radio" name="I1" value="4"> 4 </td>
                <td><input type="radio" name="I1" value="5"> 5 </td>
                <td><input type="radio" name="I1" value="6"> 6 </td>
                <td><input type="radio" name="I1" value="7"> 7 </td>
                <td><input type="radio" name="I1" value="8"> 8 </td>
                <td><input type="radio" name="I1" value="9"> 9 </td>
                <td><input type="radio" name="I1" value="10"> 10 </td>
</tr>
<tr>
<td>question3</td>
    <td><input type="radio" name="H1" value="1"> 1 </td>
                <td><input type="radio" name="H1" value="2"> 2 </td>
                <td><input type="radio" name="H1" value="3"> 3 </td>
                <td><input type="radio" name="H1" value="4"> 4 </td>
                <td><input type="radio" name="H1" value="5"> 5 </td>
                <td><input type="radio" name="H1" value="6"> 6 </td>
                <td><input type="radio" name="H1" value="7"> 7 </td>
                <td><input type="radio" name="H1" value="8"> 8 </td>
                <td><input type="radio" name="H1" value="9"> 9 </td>
                <td><input type="radio" name="H1" value="10"> 10 </td>
</tr>
<tr>
                <td><label> question4 </label></td>
                <td><input type="radio" name="A1" value="1"> 1 </td>
                <td><input type="radio" name="A1" value="2"> 2 </td>
                <td><input type="radio" name="A1" value="3"> 3 </td>
                <td><input type="radio" name="A1" value="4"> 4 </td>
                <td><input type="radio" name="A1" value="5"> 5 </td>
                <td><input type="radio" name="A1" value="6"> 6 </td>
                <td><input type="radio" name="A1" value="7"> 7 </td>
                <td><input type="radio" name="A1" value="8"> 8 </td>
                <td><input type="radio" name="A1" value="9"> 9 </td>
                <td><input type="radio" name="A1" value="10"> 10 </td>
        </tr><!-- 14 -->
            <tr>
                <td><label> question5 </label></td>
                <td><input type="radio" name="D2" value="1"> 1 </td>
                <td><input type="radio" name="D2" value="2"> 2 </td>
                <td><input type="radio" name="D2" value="3"> 3 </td>
                <td><input type="radio" name="D2" value="4"> 4 </td>
                <td><input type="radio" name="D2" value="5"> 5 </td>
                <td><input type="radio" name="D2" value="6"> 6 </td>
                <td><input type="radio" name="D2" value="7"> 7 </td>
                <td><input type="radio" name="D2" value="8"> 8 </td>
                <td><input type="radio" name="D2" value="9"> 9 </td>
                <td><input type="radio" name="D2" value="10"> 10 </td>
            </tr><!-- 15 -->
            <tr>
<tr>
<td colspan=2>
<div align="center"><input type="button" value="Score my test" onclick="javascript:tally()"></div>
</td>
</tr>
</table>
</form>
</html>

how do i pass js data to php ? i need those js data converting to php and send it by email how can i do that ? i have being finding solution all over the net , still i cant get it can any one teach me how ? or if cant is there a way to loop all radio value on html using php ? i am new to both code.

Cherry Lee
  • 13
  • 5

1 Answers1

0

You can pass in multiple ways.

  • in a way how you tried, so by document.location (redirection) - will be in $_GET in php
  • by AJAX (for example using jQuery) - will be in $_POST (or $_GET) in php
  • by html form - will be in $_POST (may be in $_GET, but shouldn't)

To answer to your question I would have to direct you to various answers:

  • learn about data collecting from HTML and using AJAX (for example use jQuery here)
  • learn about request access in PHP $_GET, $_POST, $_REQUEST
  • learn about mail sending in php (google for "mail php"), there are basic (not perfect) snippets for that