helloise Posted March 24, 2011 Share Posted March 24, 2011 i have the following code: <li>Have you read the <?php echo link_to('FAQ','util/faq') ?> ? <select id="yesnolist" onChange="getChoice(this.value)"> <option value="yes" selected="selected">Yes</option> <option value="no">No</option> </select> </li> <input type="hidden" name="text" size=30 id="yesandno"> <?php if ($_GET['yesandno'] == "no") { echo "anything!!!!!!!!!!!!!!!!!!!"; } ?> then my java script for getCoice(): function getChoice(val) { yesNo = new Array("Yes", "No"); var getsel = document.contactus.yesnolist.value; var e = document.getElementById("yesnolist"); var strUser = e.options[e.selectedIndex].value; document.contactus.yesandno.value = strUser; alert(document.contactus.yesandno.value); return strUser; } my alert will gove yes or no depending on what i chose in the dropdown but HOWCOME it does not go into the if ($_GET['yesandno'] == "no") ???? please help??? Link to comment https://forums.phpfreaks.com/topic/231571-not-getting-value-thru-_get/ Share on other sites More sharing options...
litebearer Posted March 24, 2011 Share Posted March 24, 2011 Show us the full form Link to comment https://forums.phpfreaks.com/topic/231571-not-getting-value-thru-_get/#findComment-1191664 Share on other sites More sharing options...
cyberRobot Posted March 24, 2011 Share Posted March 24, 2011 It sounds like your expecting something to happen to the page once getChoice() is activated. If that's the case, the problem is you're mixing client-side and server-side scripting which won't work. If you want the page to display something without reloading, you'll need to stick with a language like JavaScript. Otherwise, to use PHP you'll need to submit the form back to the server and display the page again with the desired results. Link to comment https://forums.phpfreaks.com/topic/231571-not-getting-value-thru-_get/#findComment-1191701 Share on other sites More sharing options...
helloise Posted March 24, 2011 Author Share Posted March 24, 2011 thanks i've changed my code a bit now, i have my JS like this now: <script type="text/JavaScript"> function getChoice(val) { yesNo = new Array("Yes", "No"); var getsel = document.contactus.yesnolist.value; var e = document.getElementById("yesnolist"); var strUser = e.options[e.selectedIndex].value; if (strUser == "no") { //go the the faq page here } return strUser; } then my html looks like this now: <div> <tr></tr> <tr></tr> <tr> <td colspan='3' align='left' class='small_header_rbc'> <h3>Frequently Asked Questions</h3> <li>Please take a moment to read the Frequently Asked Questions as the solution to your query could be waiting for you there!</li> <li>Have you read the <?php echo link_to('FAQ','util/faq') ?> ? <select id="yesnolist" onChange="getChoice(this.value)"> <option value="yes" selected="selected">Yes</option> <option value="no">No</option> </select> </li> </tr> <tr></tr> <tr></tr> </div> so i was thinking maybe i can make a call to the FAQpage in the JS when no is selected in my dropdown??? can someone help on how to do this please? thanks Link to comment https://forums.phpfreaks.com/topic/231571-not-getting-value-thru-_get/#findComment-1191711 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.