Answer the question
In order to leave comments, you need to log in
How to write in session selected value in select?
Forming a list
<select id="sel_">
<?php
$query_= "SELECT * FROM category_information";
$sql_q=mysql_query($query_);
while ($row = mysql_fetch_row($sql_q))
{
echo '<option name="op_cat_id" value="'.$row[0].'">'.$row[1].'</option>';
}
?>
</select>
Answer the question
In order to leave comments, you need to log in
How, when selecting the "op_cat_id" element, write "value" to the session?
Look for the selected element not by the option name, but by the name or identifier select
For example, by attaching a script to the select:
$('#sel_').change(function(){
var id = $(this).val();
// and then you push the value into the session with Ajax
});
It is possible through cookies: <?
// send cookie
setcookie("cookie[select]", $row[0]);
// after page reload, output cookie
if (isset($_COOKIE['cookie'])) {
foreach ($_COOKIE['cookie'] as $name => $value) {
$name = htmlspecialchars($name);
$value = htmlspecialchars($value);
echo "$name : $value
\n";
}
}
?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question