Showcasing the values of JavaScript

How can I resolve the issue depicted in the second picture? I need the value of 3 only in the USD column, with all others having a value of zero.

<div class="span3">
    <ul class="nav nav-tabs nav-stacked" >
        <?php
        foreach ( $submenu as $sm ) {
            echo '<li><a href="'.$base_url.$sm['link'].'">'.$sm['title'].'</a></li>';
        }
        ?>
    </ul>    
</div>
<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
            <h3 id="myModalLabel">Add New Daily Price Index</h3>
    </div>
    <div class="modal-body">
        <form id="myForm" method="post">

          <div class="span2">Index</div>
          <input type="text" name="indexval" id="indexval"/>
          <!--input type="hidden" value="hello" id="myField"-->

            <!--button id="myFormSubmit" type="submit">Submit</button-->
        </form>
    </div>
    <div class="modal-footer">
        <button class="btn btn-primary" id="myFormSubmit" >Save</button>
        <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
    </div>
...

First Picture:

Second Picture:

Query:

select type,indexval,delivery_date,priceval from price_indices
where delivery_date between '$sdate' and '$edate' and `type`='$type'
order by delivery_date

Answer №1

If you want to incorporate a PHP value into JavaScript, you can simply store the PHP value in a variable and then use it within your JavaScript code. Here's an example:

$amount = 5; // storing the PHP value

$('#result').html('<?php echo $amount; ?>'); // displaying the PHP value

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Not every situation calls for the same type of styling

I am struggling to override the CSS for <h1> and <h2> using specific selectors only. The changes are only being applied to one class, with <h1> changing color to green but not <h2>. Can someone please assist me in identifying where ...

Sending data to a JSON file with jQuery and AJAX: Step-by-step guide

While there are numerous tutorials available on how to retrieve data from json files using jQuery and ajax, I have been unable to find any that demonstrate how to POST data to a json file. If anyone has a script or example they could share with me on how t ...

Steps to properly create your own angular service with XHR

Exploring the world of AngularJS, I embarked on a mission to create a file upload feature along with other form data. While there are numerous scripts and plugins available, I decided to utilize my own custom service using $xhr. Despite successfully sendin ...

How to verify in HTML with Angular whether a variable is undefined

When it comes to the book's ISBN, there are instances where it may not be defined. In those cases, a placeholder image will be loaded. src="http://covers.openlibrary.org/b/isbn/{{book.isbn[0]}}-L.jpg?default=false" ...

Utilizing Asynchronous Functions within a Loop

I have a situation where I am working with an array and need to make API calls for each index of the array. Once the API call is resolved, I need to append the result in that specific element. My goal is to ultimately return the updated array once this pro ...

Separate sentence to one word per line

Can CSS be used to display each word of a sentence on a separate line? Input: <div>Hello world foo bar</div> Rendered output: Hello world foo bar It is not ideal to set the width to 1px, as specified. ...

How can I efficiently include all css from node_modules in vuejs?

For my Vue.js app built with the webpack template and vuetify, I am starting by importing the vuetify css in my App.vue. <style> @import '../node_modules/vuetify/dist/vuetify.min.css' </style> I'm wondering if this is the c ...

Issue with VueJS instance: Unable to prevent default behavior of an event

Is there a way to disable form submission when the enter key is pressed? Take a look at the different methods I've attempted along with the code and demo example provided below. SEE PROBLEM DEMO HERE Intended outcome: When you focus on the input, pr ...

Steps for accessing registration form data once the signup button has been clicked

Hello everyone! I have a code that includes login and registration forms as tabs. When we click on either one, it goes to the respective form. Now, I want to make a change by removing the Register tab and adding it as a signup button next to the login butt ...

Reset the child JSP page to its original appearance

Displayed below is a JSP page: <div id="tabs-7" style="width: 100%;"> <form:form id="deviceForm" name="" modelAttribute="" enctype="multipart/form-data"> <div class="inputWidgetContainer"> <div class="inputWidget"> <table> ...

Trying out the Send feature of Gmail API using Postman

Attempting to use the Gmail API for sending emails. Utilizing Postman as a tool to test requests and obtain correct code for web application integration, encountering an error: { "error": { "errors": [ { "domain": "global", ...

Quickest method of writing this (using jQuery)

Is there a more efficient way to accomplish this task in one line? var $d = $('<div>').addClass('clear'); $('.clearAfter').after($d); Alternatively, you can add the CSS style directly using: $('.clearAfter') ...

Encrypting data using pidCrypt in a combination of Javascript and PHP

Currently, I am in the process of developing an encryption system to secure sensitive information on my website. My web hosting service requires an additional fee for SSL, which I am not prepared to invest in at this moment. I experimented with utilizing ...

Tips for accessing the 'index' variable in *ngFor directive and making modifications (restriction on deleting only one item at a time from a list)

Here is the code snippet I'm working with: HTML: <ion-item-sliding *ngFor="let object of objectList; let idx = index"> <ion-item> <ion-input type="text" text-left [(ngModel)]="objectList[idx].name" placeholder="Nam ...

Position the Material UI Box element to the bottom of its parent container

Hello there, I've come across the following layout: <Box width="100%" height="100%" p={1}> <Box my={1} display="flex" justifyContent="center"> </ ...

Tips for ensuring that jQuery runs in the correct order within Angular 2

As a beginner with Angular 2 and asynchronous loading, I have encountered some difficulties in finding the right approach for running jQuery scripts in the correct sequence within an Angular 2 project. Despite exploring various resources such as: How to u ...

Adjust picture to fit in div and align vertically

JSFiddle In my fluid layout, I have a div with a required aspect ratio of 1:1. This div can contain text, an image, or both. The challenge is to vertically align the text and ensure the image fits within the div without exceeding its boundaries or losing ...

Caution: The trim() function requires the first parameter to be a string, but in this case,

public function Retrieve_table_data() { if($this->target_word) { $word=$this->target_word; $this->target_word = $this->database->query("SELECT stimulus_word, response_word, occurrences FROM word_associations WHERE sti ...

Can the conventional HTML context menu be swapped out for a link context menu instead?

Currently, I am working on developing a custom linkbox component that is similar to the one found on this page: Here is an example of the code: export const Linkbox = ({}) => { const linkRef = useRef(null); return ( // eslint-disable-next-l ...

Is there a way to extract and exhibit the text from an image using Python?

Could someone assist me in extracting only the text within the highlighted red area? I have been experimenting with Python but haven't been successful in achieving this. My goal is to create a script that prompts for an address, then opens Firefox (or ...