Can anyone suggest some ideas for what I want to do here












1














I am quite well versed in developing in PHP, HTML5 and CSS3 however when it comes to Javascript and Jquery I'm totally lost.



What I'm looking at doing is on my site I want to place a custom page that allows the users to select certain options which will be specified by me.



pretty much along the lines of:-



Question1?



Select one of 2 options.



option 1 moves along to question 2



however where option 2 then moves to a different question.



what I would like to do instead is to use Javascript instead so it could be question 1 select answer, then question 2 automatically populates underneath. and then depending on that answer and so on, until the end is reached.



I will include a little snippet below so it helps visualise the end goal that I am looking for:-



<?php 
$q1 = $_POST['q1'] ?? '';
$q2 = $_POST['q2'] ?? '';
?>
<?php
if(isset($_POST['q1] {
echo 'q2';
} else {
echo 'q20';
}
?>


The HTML would then be:-



<form name="script_path.ext" method="POST">
<span>Question 1?</span></br>
<select id="q1" name="q1">
<option value="yes">Yes</option>
<option value="no">No</option>
</select>
<input type="submit" name="submit"
value="Next">


obviously it would be better to use Jquery to do this as the amount of variables are going to grow as questions get added and could become an infinite loop of if_statements.










share|improve this question






















  • Yes I would be looking at it storing the answers to certain questions in a database but only displaying relevant questions as well as most answers are going to be simple yes / no answers however some will require end user input and others will need to pull other existing records in a different table. Pretty much where question 1 if answered yes will then display question 2 but if question 1 is answered no then it would need to pull say for example question 5 as the other questions would be irrelevant to that users requirements.
    – Neil-948
    Nov 22 at 21:02












  • Do you want to catch get parameters with js and then autoselect the option? I haven't understand what you mean
    – Osakr
    Nov 22 at 21:02










  • Are you using any JavaScript frameworks on the front-end? You'd greatly benefit from state management, such that comes with React or Angular
    – AnonymousSB
    Nov 22 at 21:02










  • I've not had any look with installing frameworks on my system all my coding work is done by freehand I tried installing ruby but it just doesn't behave well on this system.
    – Neil-948
    Nov 22 at 21:05










  • Eh walk before you can run, you would probably be better off starting with JQuery
    – SpeedOfRound
    Nov 22 at 21:08
















1














I am quite well versed in developing in PHP, HTML5 and CSS3 however when it comes to Javascript and Jquery I'm totally lost.



What I'm looking at doing is on my site I want to place a custom page that allows the users to select certain options which will be specified by me.



pretty much along the lines of:-



Question1?



Select one of 2 options.



option 1 moves along to question 2



however where option 2 then moves to a different question.



what I would like to do instead is to use Javascript instead so it could be question 1 select answer, then question 2 automatically populates underneath. and then depending on that answer and so on, until the end is reached.



I will include a little snippet below so it helps visualise the end goal that I am looking for:-



<?php 
$q1 = $_POST['q1'] ?? '';
$q2 = $_POST['q2'] ?? '';
?>
<?php
if(isset($_POST['q1] {
echo 'q2';
} else {
echo 'q20';
}
?>


The HTML would then be:-



<form name="script_path.ext" method="POST">
<span>Question 1?</span></br>
<select id="q1" name="q1">
<option value="yes">Yes</option>
<option value="no">No</option>
</select>
<input type="submit" name="submit"
value="Next">


obviously it would be better to use Jquery to do this as the amount of variables are going to grow as questions get added and could become an infinite loop of if_statements.










share|improve this question






















  • Yes I would be looking at it storing the answers to certain questions in a database but only displaying relevant questions as well as most answers are going to be simple yes / no answers however some will require end user input and others will need to pull other existing records in a different table. Pretty much where question 1 if answered yes will then display question 2 but if question 1 is answered no then it would need to pull say for example question 5 as the other questions would be irrelevant to that users requirements.
    – Neil-948
    Nov 22 at 21:02












  • Do you want to catch get parameters with js and then autoselect the option? I haven't understand what you mean
    – Osakr
    Nov 22 at 21:02










  • Are you using any JavaScript frameworks on the front-end? You'd greatly benefit from state management, such that comes with React or Angular
    – AnonymousSB
    Nov 22 at 21:02










  • I've not had any look with installing frameworks on my system all my coding work is done by freehand I tried installing ruby but it just doesn't behave well on this system.
    – Neil-948
    Nov 22 at 21:05










  • Eh walk before you can run, you would probably be better off starting with JQuery
    – SpeedOfRound
    Nov 22 at 21:08














1












1








1







I am quite well versed in developing in PHP, HTML5 and CSS3 however when it comes to Javascript and Jquery I'm totally lost.



What I'm looking at doing is on my site I want to place a custom page that allows the users to select certain options which will be specified by me.



pretty much along the lines of:-



Question1?



Select one of 2 options.



option 1 moves along to question 2



however where option 2 then moves to a different question.



what I would like to do instead is to use Javascript instead so it could be question 1 select answer, then question 2 automatically populates underneath. and then depending on that answer and so on, until the end is reached.



I will include a little snippet below so it helps visualise the end goal that I am looking for:-



<?php 
$q1 = $_POST['q1'] ?? '';
$q2 = $_POST['q2'] ?? '';
?>
<?php
if(isset($_POST['q1] {
echo 'q2';
} else {
echo 'q20';
}
?>


The HTML would then be:-



<form name="script_path.ext" method="POST">
<span>Question 1?</span></br>
<select id="q1" name="q1">
<option value="yes">Yes</option>
<option value="no">No</option>
</select>
<input type="submit" name="submit"
value="Next">


obviously it would be better to use Jquery to do this as the amount of variables are going to grow as questions get added and could become an infinite loop of if_statements.










share|improve this question













I am quite well versed in developing in PHP, HTML5 and CSS3 however when it comes to Javascript and Jquery I'm totally lost.



What I'm looking at doing is on my site I want to place a custom page that allows the users to select certain options which will be specified by me.



pretty much along the lines of:-



Question1?



Select one of 2 options.



option 1 moves along to question 2



however where option 2 then moves to a different question.



what I would like to do instead is to use Javascript instead so it could be question 1 select answer, then question 2 automatically populates underneath. and then depending on that answer and so on, until the end is reached.



I will include a little snippet below so it helps visualise the end goal that I am looking for:-



<?php 
$q1 = $_POST['q1'] ?? '';
$q2 = $_POST['q2'] ?? '';
?>
<?php
if(isset($_POST['q1] {
echo 'q2';
} else {
echo 'q20';
}
?>


The HTML would then be:-



<form name="script_path.ext" method="POST">
<span>Question 1?</span></br>
<select id="q1" name="q1">
<option value="yes">Yes</option>
<option value="no">No</option>
</select>
<input type="submit" name="submit"
value="Next">


obviously it would be better to use Jquery to do this as the amount of variables are going to grow as questions get added and could become an infinite loop of if_statements.







javascript jquery






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 22 at 20:53









Neil-948

112




112












  • Yes I would be looking at it storing the answers to certain questions in a database but only displaying relevant questions as well as most answers are going to be simple yes / no answers however some will require end user input and others will need to pull other existing records in a different table. Pretty much where question 1 if answered yes will then display question 2 but if question 1 is answered no then it would need to pull say for example question 5 as the other questions would be irrelevant to that users requirements.
    – Neil-948
    Nov 22 at 21:02












  • Do you want to catch get parameters with js and then autoselect the option? I haven't understand what you mean
    – Osakr
    Nov 22 at 21:02










  • Are you using any JavaScript frameworks on the front-end? You'd greatly benefit from state management, such that comes with React or Angular
    – AnonymousSB
    Nov 22 at 21:02










  • I've not had any look with installing frameworks on my system all my coding work is done by freehand I tried installing ruby but it just doesn't behave well on this system.
    – Neil-948
    Nov 22 at 21:05










  • Eh walk before you can run, you would probably be better off starting with JQuery
    – SpeedOfRound
    Nov 22 at 21:08


















  • Yes I would be looking at it storing the answers to certain questions in a database but only displaying relevant questions as well as most answers are going to be simple yes / no answers however some will require end user input and others will need to pull other existing records in a different table. Pretty much where question 1 if answered yes will then display question 2 but if question 1 is answered no then it would need to pull say for example question 5 as the other questions would be irrelevant to that users requirements.
    – Neil-948
    Nov 22 at 21:02












  • Do you want to catch get parameters with js and then autoselect the option? I haven't understand what you mean
    – Osakr
    Nov 22 at 21:02










  • Are you using any JavaScript frameworks on the front-end? You'd greatly benefit from state management, such that comes with React or Angular
    – AnonymousSB
    Nov 22 at 21:02










  • I've not had any look with installing frameworks on my system all my coding work is done by freehand I tried installing ruby but it just doesn't behave well on this system.
    – Neil-948
    Nov 22 at 21:05










  • Eh walk before you can run, you would probably be better off starting with JQuery
    – SpeedOfRound
    Nov 22 at 21:08
















Yes I would be looking at it storing the answers to certain questions in a database but only displaying relevant questions as well as most answers are going to be simple yes / no answers however some will require end user input and others will need to pull other existing records in a different table. Pretty much where question 1 if answered yes will then display question 2 but if question 1 is answered no then it would need to pull say for example question 5 as the other questions would be irrelevant to that users requirements.
– Neil-948
Nov 22 at 21:02






Yes I would be looking at it storing the answers to certain questions in a database but only displaying relevant questions as well as most answers are going to be simple yes / no answers however some will require end user input and others will need to pull other existing records in a different table. Pretty much where question 1 if answered yes will then display question 2 but if question 1 is answered no then it would need to pull say for example question 5 as the other questions would be irrelevant to that users requirements.
– Neil-948
Nov 22 at 21:02














Do you want to catch get parameters with js and then autoselect the option? I haven't understand what you mean
– Osakr
Nov 22 at 21:02




Do you want to catch get parameters with js and then autoselect the option? I haven't understand what you mean
– Osakr
Nov 22 at 21:02












Are you using any JavaScript frameworks on the front-end? You'd greatly benefit from state management, such that comes with React or Angular
– AnonymousSB
Nov 22 at 21:02




Are you using any JavaScript frameworks on the front-end? You'd greatly benefit from state management, such that comes with React or Angular
– AnonymousSB
Nov 22 at 21:02












I've not had any look with installing frameworks on my system all my coding work is done by freehand I tried installing ruby but it just doesn't behave well on this system.
– Neil-948
Nov 22 at 21:05




I've not had any look with installing frameworks on my system all my coding work is done by freehand I tried installing ruby but it just doesn't behave well on this system.
– Neil-948
Nov 22 at 21:05












Eh walk before you can run, you would probably be better off starting with JQuery
– SpeedOfRound
Nov 22 at 21:08




Eh walk before you can run, you would probably be better off starting with JQuery
– SpeedOfRound
Nov 22 at 21:08

















active

oldest

votes











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
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53437858%2fcan-anyone-suggest-some-ideas-for-what-i-want-to-do-here%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































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.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


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




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53437858%2fcan-anyone-suggest-some-ideas-for-what-i-want-to-do-here%23new-answer', 'question_page');
}
);

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







Popular posts from this blog

A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

Calculate evaluation metrics using cross_val_predict sklearn

Insert data from modal to MySQL (multiple modal on website)