-1

Good day experts!

I am stuck on a problem. This is my function.php

 function tbl_questions() {
    global $mysqlhost, $mysqluser, $mysqlpwd, $mysqldb;



$connection=mysqli_connect($mysqlhost, $mysqluser, $mysqlpwd) or die ("Verbindungsversuch fehlgeschlagen");
        mysqli_select_db($connection, $mysqldb) or die("Konnte die Datenbank nicht waehlen.");
        $sql_tbl_questions = "SELECT * FROM `questions` where istAktiv='1'";
        $quest_query = mysqli_query($connection, $sql_tbl_questions) or die("Anfrage nicht erfolgreich");

    $i = 0;

    while ($question = mysqli_fetch_array($quest_query)) {
        $i++;
        echo '<tr>';
        echo '<th>'.$i.'</th>';
        echo '<th>'.$question['question'].'</th>';
        echo '<th class="text-center"><input type="radio" name="'.$question['dimension'].'_question_'.$question['id'].'" value="0" required></th>';
        echo '<th class="text-center"><input type="radio" name="'.$question['dimension'].'_question_'.$question['id'].'" value="2.5"></th>';
        echo '<th class="text-center"><input type="radio" name="'.$question['dimension'].'_question_'.$question['id'].'" value="5"></th>';
        echo '<th class="text-center"><input type="radio" name="'.$question['dimension'].'_question_'.$question['id'].'" value="7.5"></th>';
        echo '<th class="text-center"><input type="radio" name="'.$question['dimension'].'_question_'.$question['id'].'" value="10"></th>';
        echo '</tr>';
        $dimensions = $question['dimension'];
    }
    echo '<tr>';
        echo '<th></th>';
        echo '<th>Kommentar/Ihre Anmerkung</th>';
        echo '<th class="text-center" colspan=5><textarea rows=3 cols=50 name="Kommentar"></textarea></th>';
        echo '</tr>';

    echo '<input type="hidden" name="gesamt" value="'.$i.'">';
    echo '<input type="hidden" name="dimensions" value="'.$dimensions.'">';
    echo '<input type="hidden" name="size" value="'.$_POST['size'].'">';    
    echo '<input type="hidden" name="branche" value="'.$_POST['branche'].'">';
    //echo $_POST['size'];
    //echo $_POST['branche'];   
    }`

That function.php is saving data from an questionaire which is containing values. My problem is as easy as complex. I am moving through this questionaire through an javascript:

function senden(goBack){

 if(goBack==0)
 {
  document.getElementById('page').value++;
  if( document.getElementById('page').value >9){
   document.getElementById('submitForm').action='auswertung.php';
   
  }
  document.getElementById('submitForm').submit();
 }
 else
 {
  document.getElementById('page').value--;
  if( document.getElementById('page').value <1){
   document.getElementById('submitForm').action='branche.php';
   
  }
  document.getElementById('submitForm').submit();
 }

}

And of course some html for the buttons:

  <input type="hidden" id="page" name="page" value="<?php echo $page; ?>" />
  <button type="button" id="doubleButtons" class="btn btn-default" onclick="senden(1)">Zurück</button>
  <button type="button" id="doubleButtons" class="btn btn-default" onclick="senden(0)"><?php echo $page==9?"FDC Auswerten":"Weiter";?></button>

The questionnaire got those radio buttons which i am talking about, a button for next and a button for back.

My problem is : If i am filling my questionnaire and press the back button, the filled stuff is gone! So my idea was to save everything into an array, but can you give me a hint how i have to do it?

I hope my question is quite clear, if not, please excuse me and let me know!

cmprogram
  • 1,854
  • 2
  • 13
  • 25
Arti
  • 1
  • 5

1 Answers1

0

try using history.back function?

<button onclick="history.back()">Back</button>
ha_ryu
  • 568
  • 2
  • 7
  • 20
  • but how do i save my values ( which are stored from the radio buttons) ? – Arti Nov 12 '18 at 10:03
  • store or retrieve it from form? your problem is you want to get the values from form when you press back button am I right? you can obtain their values if you save them in array, you can refer to this post, hope it helps :D https://stackoverflow.com/questions/2619163/radio-buttons-array-elements – ha_ryu Nov 12 '18 at 10:09
  • i need to store each questions value from the radio button. So the user can click on back, and the radio buttons values are retrieved. so i need both, thats the hard part about it which i dont get :/ – Arti Nov 12 '18 at 10:18