angel777 Posted January 25, 2008 Share Posted January 25, 2008 hi.. if i have 10 questions.. how do i put all into array.. where each time i click on a button next.. the next question will appear.. Quote Link to comment https://forums.phpfreaks.com/topic/87681-array-question/ Share on other sites More sharing options...
revraz Posted January 25, 2008 Share Posted January 25, 2008 Have the next button set the URL to something like page.php?question=2 and then use $_GET['question'] and use that in your array. Quote Link to comment https://forums.phpfreaks.com/topic/87681-array-question/#findComment-448513 Share on other sites More sharing options...
teng84 Posted January 25, 2008 Share Posted January 25, 2008 if you need complete code for this post this is freelance section Quote Link to comment https://forums.phpfreaks.com/topic/87681-array-question/#findComment-448519 Share on other sites More sharing options...
angel777 Posted January 25, 2008 Author Share Posted January 25, 2008 i am afraid i do not get u .. newbie here.. my code is below.. my idea is instead of display all question and counting the total .. i want to split each question by clicking on the next button.. after complete the question.. sum up the total .. how should i do that script type="text/javascript"> function checkTotal() { var total = document.listForm.total; var choice = document.listForm.choice; var choice1 = document.listForm.choice1; var sum = 0; for (i=0;i<choice.length;i++) { if (choice[i].checked) sum = sum + parseInt(choice[i].value); } for (i=0;i<choice1.length;i++) { if (choice1[i].checked) sum = sum + parseInt(choice1[i].value); } // total.value = sum; document.listForm.total.value = sum; } </script> </head> <body> <form name="listForm"> <p>2) Do you feel more self-confident than usual?</p> <ul> <Input class="checkbox" type="checkbox" name="choice" value="1" onclick="checkTotal()">Yes <br> <Input class="checkbox" type="checkbox" name="choice" value="0" onclick="checkTotal()">No <br> </ul> <p>2) Do you feel happy?</p> <ul> <Input class="checkbox" type="checkbox" name="choice1" value="1" onclick="checkTotal()">Yes <br> <Input class="checkbox" type="checkbox" name="choice1" value="0" onclick="checkTotal()">No <br> </ul> Total: <input type="text" size="2" name="total" value="0"/> Quote Link to comment https://forums.phpfreaks.com/topic/87681-array-question/#findComment-448527 Share on other sites More sharing options...
teng84 Posted January 25, 2008 Share Posted January 25, 2008 sorry man this is Java script not php you post in <a href="http://www.phpfreaks.com/forums/index.php/board,6.0.html">JS section</a> maybe you can do this.. once the user click check your hidden fields (put a hidden field that will contain the number of pages or maybe the page it display) then in you function look at that field and use that as one of the condition to get the page you're about to display and note you have to increment or decrement the value of that hidden field so you know what page you're going once next is clicked Quote Link to comment https://forums.phpfreaks.com/topic/87681-array-question/#findComment-448533 Share on other sites More sharing options...
angel777 Posted January 25, 2008 Author Share Posted January 25, 2008 hi.. the javascript is just some function.. . my whole form is PHP.. can u provide some sample code for me for my situation.. really appreciate.. Quote Link to comment https://forums.phpfreaks.com/topic/87681-array-question/#findComment-448536 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.