How do i fill an php array with my session and other variables?js
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!
javascript php html
add a comment |
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!
javascript php html
add a comment |
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!
javascript php html
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!
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();
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();
<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>
<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>
javascript php html
javascript php html
edited Nov 12 '18 at 10:04
cmprogram
1,102519
1,102519
asked Nov 12 '18 at 9:53
ArtiArti
14
14
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
try using history.back function?
<button onclick="history.back()">Back</button>
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 stackoverflow.com/questions/2619163/…
– 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
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53259609%2fhow-do-i-fill-an-php-array-with-my-session-and-other-variablesjs%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
try using history.back function?
<button onclick="history.back()">Back</button>
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 stackoverflow.com/questions/2619163/…
– 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
add a comment |
try using history.back function?
<button onclick="history.back()">Back</button>
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 stackoverflow.com/questions/2619163/…
– 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
add a comment |
try using history.back function?
<button onclick="history.back()">Back</button>
try using history.back function?
<button onclick="history.back()">Back</button>
answered Nov 12 '18 at 9:59
ha_ryuha_ryu
416413
416413
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 stackoverflow.com/questions/2619163/…
– 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
add a comment |
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 stackoverflow.com/questions/2619163/…
– 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
but how do i save my values ( which are stored from the radio buttons) ?
– Arti
Nov 12 '18 at 10:03
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 stackoverflow.com/questions/2619163/…
– ha_ryu
Nov 12 '18 at 10:09
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 stackoverflow.com/questions/2619163/…
– 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
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
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53259609%2fhow-do-i-fill-an-php-array-with-my-session-and-other-variablesjs%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown