SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Guru
    Join Date
    Jun 2009
    Posts
    813
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    problem getting param from select dropdown...

    hi,

    am getting error when trying to get param from select dropdown:

    form code:

    Code:
    <form action="dd_test.php" method="post">
    	
    	<select name="count">
    		<option selectd="selected" value="">25</option>
    		<option value="35">35</option>
    		<option value="65">65</option>
    	</select> 
    </form>
    php:
    Code:
    $countR = $_POST['count'];
    get error...

    test Notice: Undefined index: count in /Library/WebServer/Documents/tw/dd_test.php on line 7
    what on earth is the problem here....

    thank you..


  2. #2
    SitePoint Guru
    Join Date
    Jun 2009
    Posts
    813
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    oh brother.. I just figured it out...... sorry....


    but this thing is still causing me a problem...

    this is for a Twitter Search API thing...

    if I add this one line

    Code:
    $countR = $_POST['count']
    to my PHP code the search doesn't work... i.e., I don't get any results, don't get any errors.....ajax requests just hangs.......
    (whether I use "GET" or "POST"... form is action "post", but am using getJSON() method.. which I assume by default is method "GET"???

    I don't want to use method "GET" for the search because then search term appears as a param in url, and when they search for a another term the param in the url doesn't change (and I don't want to have to reload the page every time they run a new search...)

    now why is this is simple line

    Code:
    $countR = $_POST['count']
    causing the search to not work?

    again, relevant form code is:

    Code:
    <form action="" method="post">
    	show <select name="count">
    		<option selectd="selected" value="25">25</option>
    		<option value="35">35</option>
    		<option value="65">65</option>
    	</select> tweets 
    </form>
    thank you...


  3. #3
    SitePoint Guru bronze trophy
    Join Date
    Feb 2013
    Posts
    673
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)
    That error is just saying that index 'count' is not set (when you've not submitted the form) so you should check that it is set before using it.
    PHP Code:
    $countR = (isset($_POST['count']) ? "{$_POST['count']}''); 


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •