brown2005 Posted January 18, 2007 Share Posted January 18, 2007 i have a select box with these options110100after i select one i want to refresh the page but withpage.php?results=and wat ever is selected.any help please? Link to comment https://forums.phpfreaks.com/topic/34732-change-url-via-select-box/ Share on other sites More sharing options...
Orio Posted January 18, 2007 Share Posted January 18, 2007 That's javascript, not PHP.Google about the onChange event.Orio. Link to comment https://forums.phpfreaks.com/topic/34732-change-url-via-select-box/#findComment-163674 Share on other sites More sharing options...
ted_chou12 Posted January 18, 2007 Share Posted January 18, 2007 yeap, thats definitly javascript, but luckly ive got the code:[code]<select onchange="window.open(this.options[this.selectedIndex].value,'_top')"><?php function select($page, $file){if ($page == $file) echo "selected=\"selected\"";}?><option value="page.php?results=1" <?php select($page, "1");?>>Inbox</option><option value="page.php?results=2" <?php select($page, "2");?>>Outbox</option></select>[/code] Link to comment https://forums.phpfreaks.com/topic/34732-change-url-via-select-box/#findComment-163681 Share on other sites More sharing options...
DBookatay Posted January 18, 2007 Share Posted January 18, 2007 JavaScript:Insert into the <head> of the page:[code]<script>// Dropdown Redirectfunction faqRedirect(selectBox) { var faqURL = selectBox.options[selectBox.selectedIndex].value if (faqURL != "") { if (faqURL.substr(0, 4) != "http") faqURL = "../" + faqURL location.href = faqURL } }</script>[/code]Insert into the body of the page:[code]<select onChange="faqRedirect(this)"> <option>Please Select Your Choice</option> <option value="_____.php">01</option> <option value="_____.php">10</option> <option value="_____.php">100</option></select>[/code] Link to comment https://forums.phpfreaks.com/topic/34732-change-url-via-select-box/#findComment-164044 Share on other sites More sharing options...
.josh Posted January 18, 2007 Share Posted January 18, 2007 well it could be php if you want to select and submit. If you want it to get results whenever you select but not submit, then yes, you need javascript. Link to comment https://forums.phpfreaks.com/topic/34732-change-url-via-select-box/#findComment-164060 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.