Click here to Skip to main content
16,018,805 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How to get the select option lable name in php.In my code option label is different.option value is different.I want to get the name of the label.
This is my code:
XML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<select name="CATEGORY_ID">
  <option label="[Top]" value="0" selected="selected">[Top]</option>
<option label="|___Arts &amp; Humanities" value="1">|___Arts &amp; Humanities</option>

</body>
</html>
Posted
Updated 19-May-12 0:04am
v2
Comments
Sergey Alexandrovich Kryukov 20-May-12 0:13am    
You are not showing any PHP here. Do you even understand PHP works on server side?
--SA
Deepthi.T 21-May-12 0:33am    
Like this i wrote the code.I am getting the values 0,1....

1 solution

Looking at this code, I'm not sure you understand what do your want to obtain and how PHP (or rather Web) works. You page content has nothing to do with PHP until you send some HTTP request to the server. You can do one of the following: 1) wrap your control in <form> and submit a whole form with the method "POST"; process the POST data on the server side, recognize elements by their <name> attribute values; 2) use JavaScript to read the value of some controls and AJAX to send required HTTP request to the server immediately.

Both methods require knowledge of PHP API and the second one requires JavaScript. Please see:
http://www.w3schools.com/php/php_post.asp[^],
http://en.wikipedia.org/wiki/Ajax_%28programming%29[^],
http://en.wikipedia.org/wiki/XMLHttpRequest[^],
http://www.w3schools.com/ajax/default.asp[^],
http://www.w3schools.com/php/php_ajax_php.asp[^],
http://www.w3schools.com/js/default.asp[^].

Please consider the articles referenced above as a starting point. Have fun.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900