Ho to transfer select tag value in a session

Hi,

Can anyone help me how to transfer the select tag value to a session variable


<form id='assigned'  name="assigned" class='assigned'  action='asstoticket.php' method='POST'  >

<select style="width:100%" name='assigned' onchange="TicketAss('<?php echo $newticket['TickNo'];?>','<?php echo $newticket['UserName'];?>',$(this));" >
										
<option value="0">Please Select</option>
<?php foreach($AssignOptions as $TransferOption){ 
echo '<option id="assigned" name="assigned" value="', $TransferOption['MISPIC'], '">', $TransferOption['MISPIC'], '</option>'; 
}
?> 
</select>				
</form>

I tried $_SESSION[‘MISPIC’]=$_POST[‘assigned’]; but it is not working.

You do not need name attribute in option tag. Please remove it then check if it work.

same it does not transfer the value…

Open asstoticket.php
Add line:
var_dump($_POST);
Save asstoticket.php
Upload if necessary
Run page again.

is the value being put in the $_POST variable?

Also, what does the function TicketAss do in your javascript?

Here is the script.
i just want to permanently store the said value.so the value cannot be destroy after reload.


function TicketAss(ticketno,cname,sVal) {
    if (window.confirm('Assign this ticket number ' + ticketno + ' to ' + sVal.val())) {
       
		window.location.href = "asstoticket.php?tick=" + ticketno + "&name=" + cname + "&uname=" + sVal.val();
		
    }else{
	sVal.val(0);
	};
}

var forms1 = document.getElementsByTagName('assigned'),
    i;
for (i = 0; i < forms1.length; i += 1) {
    if (forms[i].className === 'assigned') {
        forms[i].onchange = TicketAss;
    }
}
</script>

It said. when i try var_dump;
array(0) { }

What do you meran by:

I tried $_SESSION[‘MISPIC’]=$_POST[‘assigned’]; but it is not working.
Are you starting the session on both pages?

Also on asstoticket, what does:

echo $_POST

give you

Then I think you should use $_GET, not $_POST. Because the script function locate you to another url built from selection value.

I agree, then you probably don’t need that JS. Change the method to Get in the form.

Yep, there’s the problem.
Either change your PHP to use $_GET,
Or change your JS to fire the form’s submit (and keep $_POST). Either way.

why add extra code when the built in functions do the exact thing? :wink:

Well I assumed from the use of POST in the form declaration that he wanted to use POST instead of GET. shrug

extra code? You replace


       window.location.href = "asstoticket.php?tick=" + ticketno + "&name=" + cname + "&uname=" + sVal.val();

with

 document.forms['assigned'].submit();

… would hardly call that ‘extra code’.

Yup i just use the same code before i post my question…but still how do i will store the $_POST[‘assigned’] in a select tag to a session variable before going to the next page.