how to get value of 'slct_s' plz help me.

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
usman_zia
Forum Newbie
Posts: 1
Joined: Tue Jun 04, 2013 2:34 am

how to get value of 'slct_s' plz help me.

Post by usman_zia »

[text]

Code: Select all

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" >
<title>PHP-Ajax, Country State City</title>
<script type="text/javascript" src="http://ajax.googleapis.com/
ajax/libs/jquery/1.4.2/jquery.min.js"></script>

<script type="text/javascript">
$(document).ready(function()
{
	
$("#cat").change(function()
{
var dataString = 'id='+ $(this).val();
$.ajax
({
type: "POST",
url: "product1.php",
data: dataString,
cache: false,
success: function(html)
{
$("#scat").html(html);
} 
});
});
});
</script>
</head>
<body>
<?php
include_once("library/function/function.php");
include_once("library/function/model.php");
include_once("library/function/image_class.php");

check_admin();
$x=new Model();
$x->get_all_cat();
include_once("logout.php");
include_once("admin_menu.php");

?>

<fieldset style="width: 600px;"><legend>Add Product</legend>
<form action="" method="post" enctype="multipart/form-data">

<table>

<tr><td>Category</td><td><select name="slct" id="cat"><option>Select</option>
<?php 
if(count($x->ids)>0)
{
    for($i=0;$i<count($x->ids);$i++)
    {
        echo "<option value='".$x->ids[$i]."'>".$x->nm[$i]."</option>";
    }
}
?>


</select></td></tr>



<tr><td>Sub_Category</td><td><select name="slct_s" id="scat"><option>Select</option>
</select>
</td></tr>
<tr><td>Title</td><td><input type="text" name="pname" /></td></tr>
<tr><td>Price</td><td><input type="text" name="pp" /></td></tr>
<tr><td valign="top">Description</td><td><textarea name="desc" style="resize: none;"></textarea></td></tr>
<tr><td>Image</td><td><input type="file" name="pi" id="sf" ></td></tr>

<tr><td colspan="2" align="right"><input type="submit" name="submit" value="add" /></td></tr>
</table>
</form>
</fieldset>

 
 </body>
 
        
        
        
           
		
		
 
 </html>
  <?php
if(isset($_POST['submit']))
	 { 
 $z=$_POST['slct_s'];
 echo $z;
	  
 
		
	 }
        
        
        
           
		
		
?>
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: how to get value of 'slct_s' plz help me.

Post by Christopher »

Using $_POST['slct_s'] is correct, but that <select> only has one <option> which should return the value "Select" because you have not set a value="". Are you sure you are not trying to get <select name="slct"> which is the one you are generating <option>'s for?
(#10850)
Post Reply