tinmanjim Posted April 27, 2010 Share Posted April 27, 2010 This is probably laughably simple, but after a couple of hours searching, I figured it might be simplest to rely on the kindness of strangers... I'm using a simple php news application called phpns. It uses categories numbered 1 - n, and before the call to display the news function one of the calling parameters is the category number(s). I have a select list with an onchange statement, and would like to refresh the page, passing the selected index for use in the new call to shownews. As I said, I know it's simple, but would greatly appreciate any assistance. Thanks Quote Link to comment Share on other sites More sharing options...
de.monkeyz Posted April 27, 2010 Share Posted April 27, 2010 How does the PHP script get the number normally? Does it use a $_GET or $_POST? A simple solution would to make the form that the select is contained in submit on change, for example if you have the forms id of "myForm" and the select was an id of "category_id" document.getElementById('category_id').onchange() { document.getElementById('myForm').submit(); } Quote Link to comment Share on other sites More sharing options...
tinmanjim Posted April 27, 2010 Author Share Posted April 27, 2010 My code looks like this: <?php if (!isset($_GET['catID'])) $catNum = 0; else $catNum = $_GET['catID']; $phpns['category'] = $catNum; include("news/shownews.php"); ?> <form name="catSelect" action="self" method="get" > <select name="catID" id="catID" onchange="catSelect.submit()"> <option value="0">Title</option> <option value="1">Category 1</option> <option value="2">Category 2</option> <option value="3">Category 3</option> </select> </form> I'm using a news package called phpns that uses the 'category' call to pass the desired category to the shownews page. This is all on the news page, so the page should reload when an option is selected, passing the selected value to $catNum, then calling phpns. I'm not sure what's wrong... Quote Link to comment Share on other sites More sharing options...
de.monkeyz Posted April 27, 2010 Share Posted April 27, 2010 action="self" is not valid. It will try to point to the file called "self". If you want a form to submit to the page it is on. use action="". A blank action submits to itself. Quote Link to comment Share on other sites More sharing options...
tinmanjim Posted April 27, 2010 Author Share Posted April 27, 2010 That was it! Thanks!! Quote Link to comment 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.