kat35601 Posted October 16, 2015 Share Posted October 16, 2015 (edited) I want to add Javascript called encode() and show below my results of my page. the barcode should be of $Serial The page works but I do not get a barcode....I don't get any error. This is my first time to try to add a javascript to php <html> <head> <title>Status Screen</title> </head> <body> <?php include 'db.php'; $serial='14417504017'; ?> <link rel="StyleSheet" href="barcode.css" type="text/css" /> <script src="barcode.js"></script> <script type="text/javascript"> function encode() { var strValue = document.getElementById("$serial").value; var strBarcodeHTML = code128(strValue); document.getElementById("barcode").innerHTML = strBarcodeHTML; } </script> </head> <?php //=$_GET["id"]; $connect =odbc_connect("removed"); if(!$connect) { exit("Connection Failed: " . $connect); } $sql = $sql_redtag_select; $sql .= $sql_case1; $sql .= $sql_truck; $sql .= " FROM WIP_master left join m1_DC.dbo.SalesOrders on m1_DC.dbo.SalesOrders.ompSalesOrderID=OrbeData_KithKitchens.dbo.WIP_master.ompSalesOrderID left join m1_DC.dbo.UTRUCK ON m1_DC.dbo.UTRUCK.UTRTRUCKNUMBER=m1_DC.dbo.SalesOrders.UOMPTRUCKNUMBER where OrbeData_KithKitchens.dbo.WIP_master.serial='$serial' and (OrbeData_KithKitchens.dbo.WIP_master.status not in ('1','25','50')) and( redtag='Y' and redtagclosed !='Y' or (redtag='N' and m1_DC.dbo.SalesOrders.uompschedulenumber like 'S%' and m1_DC.dbo.SalesOrders.ompclosed <> -1 ) ) order by OrbeData_KithKitchens.dbo.WIP_master.uompschedulenumber,uomlSorP,upsdescription,jmaPartID "; $result =odbc_exec($connect,$sql); if(!$result){ exit("Error in SQL"); } ?> <div class="barcode" id="barcode"></div> <?php include ("redtag_serial_results.php"); odbc_close($connect); echo "<script type='text/javascript'>" ,"encode();" , "</script>" ?> </body> </html> Edited October 16, 2015 by kat35601 Quote Link to comment https://forums.phpfreaks.com/topic/298643-trying-to-add-a-barcode-to-my-page/ Share on other sites More sharing options...
Solution hansford Posted October 16, 2015 Solution Share Posted October 16, 2015 I don't know what you are trying to do, but PHP and JavaScript are two completely different languages and one has no knowledge that the other even exists. You can pass data to PHP through form fields, hidden and others or through ajax. Quote Link to comment https://forums.phpfreaks.com/topic/298643-trying-to-add-a-barcode-to-my-page/#findComment-1523458 Share on other sites More sharing options...
kat35601 Posted October 16, 2015 Author Share Posted October 16, 2015 ok Thanks Quote Link to comment https://forums.phpfreaks.com/topic/298643-trying-to-add-a-barcode-to-my-page/#findComment-1523464 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.