spdavis Posted May 14, 2022 Share Posted May 14, 2022 Hi I wonder of anyone with HTML, PHP knowledge can help me ? Using Excel and two sheet lookup with dummy data, to create the dropdown select functions.; I then converted this into HTML Finally worked out how and added some Javascript that links to the HTML, and so can retrieve what is required using <div IDs="#variables"> - Button triggered (but need to workout out refresh updating) However, the script must have those retrieved variables link to PHP and be transferable on to a payment API as a string (?) of whatever was selected and it's total price - That's now over my head Does anyone have experience of passing Javascript to PHP that maybe can advise? The HTML file included in link below, is the product of Excel 2003, also included and an Excel 2019 version to test forward compatablity For some odd reason - I can not link an image URL or drop a zip file here ☹️ ??? Working example of the HTML - HERE Quote Link to comment https://forums.phpfreaks.com/topic/314789-exceexcel-to-html-but-lost-to-php/ Share on other sites More sharing options...
ginerjm Posted May 14, 2022 Share Posted May 14, 2022 (edited) Huh? How about you just try and tell us in plain english (that means no mention of html,php, or js) what you want to accomplish with the data you currently have stored in a spreadsheet? Obviously you are not happy with it being in that format and you want to do something else. Tell us what that is. Edited May 14, 2022 by ginerjm Quote Link to comment https://forums.phpfreaks.com/topic/314789-exceexcel-to-html-but-lost-to-php/#findComment-1596231 Share on other sites More sharing options...
spdavis Posted May 14, 2022 Author Share Posted May 14, 2022 (edited) You come to a PHP support site to be told you don't mention PHP, HTML or Javascript - wtf ?!! If this abusive reply is an example of help on offer here - No point of staying I quote "Does anyone have experience of passing Javascript to PHP that maybe can advise?" - Answer I thought - YES I have "Javascript that links to the HTML, and so can retrieve what is required using <div IDs="#variables"> - My situation, and why here In context "...the script must have those retrieved variables link to PHP and be transferable on to a payment API as a string (?) of whatever was selected and it's total price " - Oh look, I am here asking how to move a Javascript variable over to a PHP variable to use within a PHP API used in e-comm If this is not English enough for anyone - This already this site has issues Edited May 14, 2022 by spdavis Quote Link to comment https://forums.phpfreaks.com/topic/314789-exceexcel-to-html-but-lost-to-php/#findComment-1596240 Share on other sites More sharing options...
ginerjm Posted May 14, 2022 Share Posted May 14, 2022 (edited) Sorry - not enough for this dummy. My thoughts were that perhaps there was a clearer way to solve your riddle if we knew what your overall goal was. You threw some things at us and then ended by asking about js->php. Apparently you don't believe in getting other opinions as a solution. Edited May 14, 2022 by ginerjm Quote Link to comment https://forums.phpfreaks.com/topic/314789-exceexcel-to-html-but-lost-to-php/#findComment-1596241 Share on other sites More sharing options...
spdavis Posted May 15, 2022 Author Share Posted May 15, 2022 (edited) Are you for real? I am asking about Java and PHP in a forum about PHP and the best this place has to offer, is bluddy cartoon I'm done with morons Edited May 15, 2022 by spdavis Quote Link to comment https://forums.phpfreaks.com/topic/314789-exceexcel-to-html-but-lost-to-php/#findComment-1596252 Share on other sites More sharing options...
ginerjm Posted May 15, 2022 Share Posted May 15, 2022 As you can see from the lack of responses, nobody here understands what you are asking. Lots of us know how to use JSON to go from JS <> PHP. The first question that we are all probably asking is "why does he need to do this?" and that is why I asked for a simple description of what your overall goal is/was. You are not used to intelligent questions I guess and that is what is making you so irate. Many times on these forums when the poster steps back and explains what he wants to do (rather than trying to make us see what he has got himself into), the solution becomes clearer and simpler and gets resolved. I'm trying. Quote Link to comment https://forums.phpfreaks.com/topic/314789-exceexcel-to-html-but-lost-to-php/#findComment-1596271 Share on other sites More sharing options...
spdavis Posted May 17, 2022 Author Share Posted May 17, 2022 (edited) So to get help here .. I have to go through the BS of hoop jumping first? Why do I need this IS NOT what I thought this so called forum was about. - It's I need an answer, not play child games with patronizing jokes And IF YOU are the 'spokesperson on behalf of this pantomime', then I am wasting my time - Because no frekin' person here knows how to answer a BASIC question.. HOW DO I GET a variable from JAVA to PHP ?? I have JAVA variable that are shown to screen not captured by PHP - Even a soding monkey can drag down my working example and figure that out - YOU clearly can't So just go away,troll somebody else - Stop replaying... Edited May 17, 2022 by spdavis Quote Link to comment https://forums.phpfreaks.com/topic/314789-exceexcel-to-html-but-lost-to-php/#findComment-1596399 Share on other sites More sharing options...
Barand Posted May 17, 2022 Share Posted May 17, 2022 The usual way to communicate between JS and PHP is by using an AJAX request. Quote Link to comment https://forums.phpfreaks.com/topic/314789-exceexcel-to-html-but-lost-to-php/#findComment-1596400 Share on other sites More sharing options...
spdavis Posted May 17, 2022 Author Share Posted May 17, 2022 (edited) Thank you for the reply... I struggle with javascript, but managed to work that out.. I have gentleman who is not a web builder, showing me a site that was written in PHP. He wants a simple cut paste solution for his site, without the eye watering cost of getting somebody to do this. He was told cut and paste - Thats the background Ajax is anther OMG language that is looking to be a step backwards before PHP - Unless I have that understanding wrong <div IDs="#variables"> <--- this is a variable unattached I believe Edited May 17, 2022 by spdavis Quote Link to comment https://forums.phpfreaks.com/topic/314789-exceexcel-to-html-but-lost-to-php/#findComment-1596401 Share on other sites More sharing options...
Barand Posted May 17, 2022 Share Posted May 17, 2022 https://developer.mozilla.org/en-US/docs/Web/Guide/AJAX/Getting_Started Quote Link to comment https://forums.phpfreaks.com/topic/314789-exceexcel-to-html-but-lost-to-php/#findComment-1596402 Share on other sites More sharing options...
spdavis Posted May 17, 2022 Author Share Posted May 17, 2022 (edited) Okay... Thanks for your replay. And appreciate your time.. I am looking at the page suggested and already I am going backwards. I am simply no programmer. Excel to HTML by Excel plugin And several, several hours trying to work out the terminology required to then work out, how to then use Google to retrieve the script I have finally used This Ajax is now a massive step backwards and has layered a totally different language - And a mass of 'server' related issues, isn't helping. But to then read XML ?!! Sorry... I obviously asking a question I have seen various answers too, and proving my HTML page example of where I am, was pointless Edited May 17, 2022 by spdavis Quote Link to comment https://forums.phpfreaks.com/topic/314789-exceexcel-to-html-but-lost-to-php/#findComment-1596403 Share on other sites More sharing options...
gizmola Posted May 17, 2022 Share Posted May 17, 2022 Let's see if we can clarify some things about this project. From reading your initial post, and looking at your link, here is my interpretation of what you are asking: It appears that what you want is a shopping cart You have arrived at an html form While this may have started with excel, that is not relevant to what you eventually arrived at, which again is the simple html form and associated javascript Now that you have this form and javascript you want to expand its functionality The drop down lists of the form should be sourced from server side data rather than being static data in the html While not clear, you may desire some interactivity in the form based upon selections in the drop downs. You desire to have server-side processing of an order on your site which includes integration of a payment gateway If these requirements are correct, then my initial response to you is that this is a non-trivial set of requirements. It most certainly can be accomplished using HTML, Javascript and PHP, but regardless of the tech stack involved, this is a significant project. As a point of clarification, HTTP protocol is based on request & response. The client makes a request for a resource (URL). This request can be of a few different types. In the case of a form like the one you mocked up, that request is typically going to be a POST. When the server receives a request, it then returns a response. Typically that response is the HTML that is then assembled by the client/browser. At that point, there is no connection between the client and server. The connection to the server is closed, and interaction with the html page is happening on the client's browser. All javascript in the page is running inside the browser. These basics limit the level of interactivity possible in a web application. "Ajax" was an extension to the javascript standard intended to allow javascript in a fully rendered html page, to be able to make additional requests, without the client having to do another full HTTP request, which in turn would require the browser to have to reinterpret and rebuild the page. Ajax isn't a separate language -- it's just an extension to the built in javascript api that the browser provides. It allows a rendered html page to include javascript code that can make network requests which typically will be for the purpose of getting data from the server. It is nothing more nor less than that. It's also important to understand that traditional pre-ajax web applications were still capable of doing everything that ajax does -- only in a manner where all interaction required a normal HTTP request/response cycle. You can have a form, and when the user changes a drop down value, the form can be submitted and the desired HTML/javascript/css source can be returned based on the modifications made to the form. It's just not as efficient or user friendly as a page that incorporates ajax, and additional javascript code to manipulate the browser's DOM using data that may have been returned from the ajax call(s). Putting the complexity question aside, it would help to break things down into individual parts. For each drop down, what is the source of the data? Is it coming from a database? Then you need a PHP script that returns the drop down data and returns it, preferably in json format. You then need javascript code that can take the json data and recompute the relevant DOM object (in this example, the drop down). You also clearly will need a serverside script that accepts the submitted form, and if everything checks out, saves the order, and then makes the payment gateway request for payment processing. The status of that payment gateway request from the PHP script to the payment gateway then needs to be saved in the order, and a response returned to the client. None of this is actually stated in your question, so I'm extrapolating additional stages and steps that I know exist for any shopping cart/ecommerce application. Again this is a big project, with a lot of complexity that requires a solid foundational understanding of html/javascript with ajax/json/http protocol/PHP network client request. Phpfreaks exists to help people of any level work towards their goals, and aims to help advise and educate. I hope this might give you a better idea of what you will need to accomplish from a technical standpoint, and that this is not a simple project for which a simple solution exists. Because ecommerce is non-trivial, often the best way to get to a solution, is to utilize a commerce platform like Shopify, or a CMS like wordpress with an extension like woocommerce. 1 Quote Link to comment https://forums.phpfreaks.com/topic/314789-exceexcel-to-html-but-lost-to-php/#findComment-1596404 Share on other sites More sharing options...
spdavis Posted May 17, 2022 Author Share Posted May 17, 2022 (edited) Thank you for a fully comprehensive replay... I'm going to hopefully answer this based on my understanding "For each drop down, what is the source of the data? Is it coming from a database?" Each drop down used (4) is integrated within the HTML, so no database is used. I know from research, this is a bad method, but the Excel converter, does what it does <select name="p1B3" id="p1B3" size="1" onchange="recalc_onclick('p1B3')" tabindex="2" class='ee104' style=' width:100% '> <option value="Vinyl" selected>Vinyl</option> <option value="R Vinyl" >R Vinyl</option> <option value="PVC" >PVC</option> </select> The value element is replaced by converter. But retains numeric value public side from the script above I used value by ID to create a Div statement (?) var sMaterial = document.getElementById("p1B3"); selectedValue = sMaterial.value; document.querySelector("#sMaterial").outerHTML = selectedValue; And this in turn becomes <div id="sMaterial"></div> At this point, the 1 page requirement has been maintained. Because the original site is not a CMS site, no SQL. So what ever goes up must be literally Cut'n'past The step from here is the reason for coming here - I am aware that there are many process of how to do.. BUT my background in Excel is not web programming I have been told by my husband that if it can be done from a single page position, it would need the HTMLDivElement - an error I keep getting. To be a modified Java, to pass the script over to PHP as a variable. Knowing this to be the wrong syntax... $Material = "<script>document.getElementById("p1B3")</script>"; <?php echo $Material;?> ... or for PHP to look up the ID from HTML Yes, in this case it's a single off the cuff e-comm addition to a web page. Ebay has a cut'n'past 'buy now' button the web owners want to use this, the idea is to graft what I create into the API and pass what ever over to their server to process I provide a TXT file that is in fact HTML. That shows on a button press the drop downs work, and calculations work and the right selection and values are correct. I have yet to work out how to reset the button. but the elements shown, would be whats passed over to a pay now button sheet.txt Edited May 17, 2022 by spdavis Quote Link to comment https://forums.phpfreaks.com/topic/314789-exceexcel-to-html-but-lost-to-php/#findComment-1596405 Share on other sites More sharing options...
gizmola Posted May 18, 2022 Share Posted May 18, 2022 I looked more closely at your page, and I have a better idea of what you have, and how you got it. To answer your immediate question, the way you would get data to a PHP script, is to send that data from your form via a POST. This means that your form needs to submit the data with a standard HTTP request. I don't want to spend too much time with your current form, for reasons I'll explain, but in regards to its current html you have this: <form id="formc" name="formc" method="post" action=""> Let's assume that your PHP script is available in the document root of your site, and the name of the script is "process_order.php" Then this would need to be: <form id="formc" name="formc" method="post" action="process_order.php"> The button that you currently have named "display" would need to be changed to a submit button. You could change some code there to do the processing you need, and put the contents into a hidden field in your form. When submitted, the PHP script will receive the contents of the form in a superglobal array named $_POST. Using that data, the script can then send it along to your payment system in whatever way is required. Here are some significant issues you need to understand: I now understand why you approached this question in regards to excel. You used some facility of excel to take some spreadsheets and generate a version of it in html and javascript. Unfortunately the code that is generated is not designed to be modified or enhanced. It includes a number of irrelevant functions and variables and code that serve the purpose of its origin, but have little to no value as a solution. It is very important for you to understand that javascript runs on the client, and calculations and derivations that involve money can not be trusted. Your javascript can calculate whatever it wants, but once someone understands what is being sent to the server as a result, they can simply bypass that and send the result they want. For example, sending an order where they get 5 items, but at the price of 1. This is a problem as old as the web, and while there are many sophisticated methods for taking care of this, the key one is to have the server code validate the order. For that reason, your server needs the same data available to the javascript, in terms of the items, pricing and options. Typically you have this code on the server, and use the server to generate the html and javascript the client uses, so that the client and server have the same source of data. Even in that case, you still need to use the server data to verify that the data wasn't tampered with. Your form is actually very simple, and there is really no value to any of the excel additives. I'm again guessing this was your way around the fact that you don't really know HTML, CSS, javascript or PHP well enough to code this up yourself. A competent web developer would have everything you need in a day, hand written code, possibly integrating some common css libraries or frameworks, and with clear and sensible code that can be maintained. A significant concern for any person would be the need to change your application due to changes in product availability, pricing or vat%. Your app would need to be modified anytime any of those variables change, which is pretty far from a basic level of competence. While I understand that you have this generated code, and your hope was to use it as a basis for getting to your final product, it would take any developer far more time and effort to attempt to do so, than to code it from scratch, which would also provide a far superior and maintainable solution than you will ever get trying to hack code that was generated for you, and has the remnants of excel links in the names of html elements and generated javascript function code. I am sure this is not the news you were hoping for, but I have to be candid that what you currently have is basically spaghetti, that will need a lot of work to get it into a form that looks valid and professional enough to satisfy a customer. As a mockup of what is actually needed however, it does a good job of demonstrating the product, pricing and options a page needs to implement. My advice to you would be to engage a professional developer to create this code for you, using the specifications discussed in this thread and via any additional communication you desire. You are certainly welcome to continue to pursue help here, but on the other hand, this is a community aimed at developers and not suitable to people who used a code generation system to create something that is convoluted and beyond their understanding, with the hopes of fashioning that into a solution for their business without having to learn the things a web developer knows. I'll just conclude this by saying that my opinions are based upon decades of professional experience, and I've seen questions similar to yours many many times. If you want to move forward, you will need to learn an awful lot about programming for the web, which is a highly technical and complicated pursuit. If you were hoping for a short cut where you can get what you have fashioned into a solution, I am afraid that is highly unlikely in my experience. Developers like myself who make our livings doing this, and frequent this forum as a way of giving back to it, simply would not take on a project like this, even though I can tell you that I could modify it in whatever ways you might want or need. I wouldn't for the reasons I stated, and neither should you. Quote Link to comment https://forums.phpfreaks.com/topic/314789-exceexcel-to-html-but-lost-to-php/#findComment-1596410 Share on other sites More sharing options...
spdavis Posted May 24, 2022 Author Share Posted May 24, 2022 I provide a TXT file that is in fact HTML, because HTML can not be directly uploaded - I get that Where this was posted, it for some reason was removed, but not by me ?? I have taken on board the suggestions given - And while I take a level of exception to the language used. It is unfortunate that what started as a simple request, becomes so patronising I may not as a newbie to this site, know its every rule or requirement, but I least expected to be playing mind games - Is this the norm here - to mob newbies and basically abuse them? It must make you feel so superior - My hubby was right Freaks IS APPROPRIATE for this site Quote Link to comment https://forums.phpfreaks.com/topic/314789-exceexcel-to-html-but-lost-to-php/#findComment-1596607 Share on other sites More sharing options...
ginerjm Posted May 24, 2022 Share Posted May 24, 2022 You apparently do not communicate at the same level as most IT professionals, whom you are dealing with here. What is being said is to not only clarify what you are doing incorrectly but also the background as to why you need to change the things you are doing. I have read some pretty detailed explanations on this topic from very talented and extremely dedicated Pros about what you need to do but apparently you are not ready to get into this business that deeply. Your responses tell me that you do not understand this business. That's not a condescending answer but simply the assumption that I (and perhaps others) are getting from your repeatedly abusive responses. You have chosen a topic that is very complex for many long-time users of PHP and you are simply not ready for that it seems. Despite the attempts from a couple of our best and brightest to involve you and educate you you insist on being hurtful and dismissive of the time and effort that has been put into trying to help you. Good luck. Quote Link to comment https://forums.phpfreaks.com/topic/314789-exceexcel-to-html-but-lost-to-php/#findComment-1596608 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.