how to send javascript variable as a php parameter -


hi have javascript function opens pop-up window , opens php file want send parameter doesnt work parameter sent variable name instead of value here script

             <?php    if($addflag == 0){ echo " <script type=\"text/javascript\"> function mopen(){ var mobj=document.getelementbyid('dtype').value; //// variable shown name instead of value window.open('quotprin.php?vouchno=' . urlencode($getvouch) . '&dtype=mobj','popupwindow','height=800,width=950,left=100,top=100,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,location=no,directories=no, status=yes'); } </script> ";  echo "<td>"; echo '<font color="red">print on letter head</font> <input type="checkbox" id="dtype" name="dtype" value="1" checked="checked" />'; echo '<input class="cmdprint" type="button" id="submit" name="print" value="print" onclick="mopen();"></td>'; echo "<td>"; }             ?> 

this not original code, works. have many escape slashes , single or double quotes. can confusing figure out errors this.

<?php   $getvouch = isset($_get['getvouch'])? $_get['getvouch'] : null;  ?>      <script type="text/javascript">     function mopen(){        var mobj=document.getelementbyid('dtype').value;        var url="quotprin.php?vouchno=<?php echo $getvouch; ?>&dtype="+ mobj;        window.open(url,'popupwindow','height=800,width=950,left=100,top=100,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,location=no,directories=no, status=yes');     }     </script>      <table><tr><td>     <font color="red">print on letter head</font>     <input type="checkbox" id="dtype" name="dtype" value="1" checked="checked" />     <input class="cmdprint" type="button" id="submit" name="print" value="print" onclick="mopen();"></td>     </tr></table> 

most important here see how "getvouch" variable added getmobi url.

if use url: add-a-javascript-var-and-send-it-with-post.php?getvouch=6

get mobi links : quotprin.php?vouchno=6&dtype=mobj

if not issue, please explain little better.

update. see error did not escape mobj variable in url. try changes.


Comments

Popular posts from this blog

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