php - Add a javascript var and send it with post -


i've got code:

$image_action = $_post['image_action'];    echo '   <form action="" method=post onmousedown="rightbutton(event)"> <input type="image"               src="image.jpeg"               style="cursor:crosshair"  />            </form>      ';   <script type="text/javascript"> function rightbutton(event) {     if(event.button==2) {  document.getelementbyid("click").innerhtml="last action: right click";  }     else{         if(event.button==0) {  document.getelementbyid("click").innerhtml="last action: left click";  }           else {             if(event.button==1) {  document.getelementbyid("click").innerhtml="last action: middle click";  }         }     }  } </script> 

well, i'm trying information mouse button user clicked in new page, in new page, i'll diferent things accordingly. trying :

method = method || "post"; var hiddenfield = document.createelement("input");     hiddenfield.setattribute("type", "hidden");     hiddenfield.setattribute("name", image_action);     hiddenfield.setattribute("value", event); form.appendchild(hiddenfield); document.body.appendchild(form); form.submit(); 

but got error: undefined index: key


Comments

Popular posts from this blog

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -