Get Pizza as value

Hi

I want to get 2 values from this form
id = 1
name = Pizza

At present i am getting only id

<!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=iso-8859-1" />
<title>Untitled Document</title>
<script>
function getList(category_id)
{
  var id = document.form1.category.value;
  window.location='page.php?id=' + id;
}
</script>
</head>

<body>
        <form name="form1">
            <select name="category" id="category" onchange="getList(this.value)">
            <option>SHOP BY CATEGORY</option>
             <option value="1">PIZZA</option>
             </select>
            </form>
        </div>
</body>
</html>

Thanks
Vineet

Hi,

This should work:

<!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=iso-8859-1" />
    <title>Untitled Document</title>
  </head>
  <body>
    <form name="form1">
      <select name="category" id="category" onchange="getList(this)">
        <option>SHOP BY CATEGORY</option>
        <option value="1">PIZZA</option>
      </select>
    </form>

    <script>
      function getList(sel){
        var id = sel.value,
        text = sel.options[sel.selectedIndex].text;
        window.location='page.php?id=' + id + '&text=' + text;
      }
    </script>
  </body>
</html>

Thanks Pullo

It works fine

Thanks
Vineet

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.