\n\nHth, cmiiw","upvoteCount":6},{"@type":"Answer","text":"Praveen Soni Then redirection by the drop-down will not work, but I have tested, neither inside nor inside work with the drop-down.\n\nMaybe others can suggest a better option. Good luck 👍","upvoteCount":5},{"@type":"Answer","text":"You forgot to define $i.","upvoteCount":2},{"@type":"Answer","text":"Ipang what if user disabled JavaScript","upvoteCount":2},{"@type":"Answer","text":"Ipang Yes you are right... I also tried the same.","upvoteCount":2},{"@type":"Answer","text":"Maneren It came from my project so i forget to get the line before the code.","upvoteCount":1}]} } CoursesCoursesCode CompilerCode CompilerDiscussPricingTeamsLog inRegisterMenu+ 1<a> tag not working inside while loop on option tag in phpecho "<select>"; while($i) { echo '<a href="pageToLink.php"><option>Something</option></a>'; $i--; } echo "</select>";php22nd Feb 2019, 6:51 PMPraveen Soni6 AnswersSort by: VotesAnswer+ 6I tried using links with options in <select> but it didn't work, even after having `$i` variable set in place. Maybe you can setup `onchange` event handler for the <select>, and use JavaScript to redirect instead, although I'm not sure if redirection works in Code Playground. <select id='links' onchange='surf_to()'> <option value=''>Choose a link</option> <?php $i = 5; while($i) { echo "<option value='pageToLink.php?linkId=$i'>Link $i</option>"; $i--; } ?> </select> <script> function surf_to() { var url = document.getElementById('links').value; if(url.length === 0) return false; console.log(url);//window.location.href = url; } </script> Hth, cmiiw22nd Feb 2019, 8:54 PMIpang+ 5Praveen Soni Then redirection by the drop-down will not work, but I have tested, neither <a> inside <option> nor <option> inside <a> work with the drop-down. Maybe others can suggest a better option. Good luck 👍23rd Feb 2019, 10:05 PMIpang+ 2You forgot to define $i.22nd Feb 2019, 7:58 PMManeren+ 2Ipang what if user disabled JavaScript23rd Feb 2019, 5:19 PMPraveen Soni+ 2Ipang Yes you are right... I also tried the same.24th Feb 2019, 4:39 PMPraveen Soni+ 1Maneren It came from my project so i forget to get the line before the code.23rd Feb 2019, 5:20 PMPraveen SoniAnswerOften have questions like this?Learn more efficiently, for free:Introduction to Python7.1M learnersIntroduction to Java4.7M learnersIntroduction to C1.5M learnersIntroduction to HTML7.5M learnersHot todayC pointers 1 VotesPython 0 VotesSlicing in python 1 VotesSQL 0 VotesControl flow 0 VotesAbout progress 0 VotesWhich mobile offline app can I use for HTML 0 VotesFront-end vs Full-stack 1 VotesAbout our Capstone product "Ecocambio" We don't know how to code and how electronics would connect. 0 VotesHOW CAN I CREATE A GAME AS BEGINNER 0 Votes
echo "<select>"; while($i) { echo '<a href="pageToLink.php"><option>Something</option></a>'; $i--; } echo "</select>";
Learn more efficiently, for free:
Introduction to Python
7.1M learners
Introduction to Java
4.7M learners
Introduction to C
1.5M learners
Introduction to HTML
7.5M learners