Note that there are some explanatory texts on larger screens.

plurals
  1. PORunning sinlge line of javascript code?
    primarykey
    data
    text
    <p>The following is the problem I'm having. I've been working with php, and that's all well and good. The problem I am having is with JavaScript. My mentor helped me get a JavaScript set up to do the work in the background, so that's not my problem. I am so unlearned in JavaScript as to not even know to run the command in the below segment. The JS code has been implemented with an tag as the href, so I know it works, just not how to apply it here.</p> <pre><code> &lt;?php if (isset($_GET['item'])) { ** This way it is dependent on them having created a product and the add page redirecting them with all required info to pop up the edit form. ** ?&gt; ** This is the section I have the problem with... No idea how to implement the following correctly. ** &lt;script&gt; openEditItemForm(&lt;?php echo $_GET['item'] ?&gt;); &lt;/script&gt; &lt;?php } else{ } ?&gt; </code></pre> <p>Sorry if this seems to be a rather ridiculous question, but as I said I have had extremely little exposure to JS and have no idea how to even find what I'm looking for in searches.</p> <p>Edit: Okay, so I kinda left this open ended what this was for... This is a back-end section where my client will be adding items to his website. The "openEditItemForm" is defined elsewhere and has worked at another point on the page. This isn't my problem. My problem on this section is actually having the code run when the page is reopened and the url contains the item identity. After having changed the code to what was recommended with the json_encode and so forth, it is still not completing the function it was created to do.</p> <p>Also, thank you Rick Burgess for the explanation as to why to include the json_encode and to Brad and steveukx for the updated code.</p> <p>Again, I'm lost when it comes to this, so I may be looking for the wrong deal again. That code is supposed to open a dialog box with an edit form in the box. Works elsewhere on the page in another form (as noted above in the href section of an &lt; a > tag). Am I expecting something that won't happen?</p> <p>Second Edit: Okay, so what I overlooked was that the function that I was trying to get to work already worked... The coding the the guys below provided helped immensely. Works like a charm. It now calls the dialog once the customer inputs an item identifier. Awesome!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload