PHP WordPress get selected text value of a drop down box

I have searched the net and this site but havent been able to find an answer.

I have a dropdown box which I need to get the text value of so I can perform some validation on it. I am working with a script which is already developed and I am modifying it so would like a simple fix.

Read More

When I call the request I am getting the categoryID (-1) and not the actual text value. The value isnt unique so I cant perform validation on this.

This is the code Im using and the details of the drop down.

<select id="catID" class="postform" name="cat"

$post_price_status2 = $_REQUEST['catID'];

if(trim($post_price_status2) == 'Select a Location') {
    $catError = 'Please enter a price / select an Ad Typess.';
    $hasError = true;
}

The drop down is also set to read only.

Related posts

1 comment

  1. When you post data PHP look for name, not ID.
    Change select name to be catID or change to $_REQUEST[‘cat’].

Comments are closed.