Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6560003
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:24:16+00:00 2026-05-25T13:24:16+00:00

In a header file i have which is populated by PHP: <script type=text/javascript> var

  • 0

In a header file i have which is populated by PHP:

<script type="text/javascript"> 
var packages = {};
packages[1] = {title:'Pack 1',price:7.50,setup:0.00,template:0};
packages[2] = {title:'Pack 2',price:12.00,setup:0.00,template:0};
packages[3] = {title:'Pack 3',price:25.00,setup:75.00,template:1};
var templates = {};
templates[4] = {title:'Template 1'};
templates[5] = {title:'Template 2'};
templates[6] = {title:'Template 3'};
</script>    

<script type="text/javascript" src="/include/jscript/form.inc.js"></script> 

Now in the form.inc.js i want the content of the vars packages. So like:

function updatePrices(){
    var package_price = 0;
    var setup_price = 0;

    var package = $_2('#package_select').val();

    package_price += packages[package].price;
    setup_price += packages[package].setup;

    $_2(".package_price").html("&pound;"+package_price);
    $_2(".setup_price").html("&pound;"+setup_price);
    $_2(".total_price").html("&pound;"+(package_price+setup_price));
}

You see here: packages[package].price that packages[1].price and should show 7.50, but i dont think the var packages is being passed though!

Any help would be awesome thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T13:24:16+00:00Added an answer on May 25, 2026 at 1:24 pm

    Your script isn’t being run because it has a syntax error in it:

    var packages = {};
    packages[1] = {title:'Book'In',price:7.50,setup:0.00,template:0};
    /intake/:21SyntaxError: Parse error
    packages[2] = {title:'Book'In Plus',price:12.00,setup:0.00,template:0};
    packages[3] = {title:'Full Monty',price:25.00,setup:75.00,template:1};
    var templates = {};
    templates[4] = {title:'Template 1'};
    templates[5] = {title:'Template 2'};
    templates[6] = {title:'Template 3'};
    

    Notice that you’re using single quotes to mark the title strings, but two of the titles have single quotes in them. You need to escape the single quotes with a slash, like so:

    packages[1] = {title: 'Book\'In',price:7.50,setup:0.00,template:0};
    

    Please look at your browser’s JavaScript/Error Console. It’ll do wonders for you =D

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a common HTML header file which I use in several PHP files.
I have C++ project (VS2005) which includes header file with version number in #define
I have a PHP script that pushes the headers to allow a file to
Basically I have code which looks like this inside a header file: class Bar;
I have a header file in which I have defined a struct. I want
I have A header file which contains declaration of a function, let's call it
I have a header file which declares the prototype for the constructor. In a
Following the post , if I have header file,which has some functions implementations in
I have a class which defines the following members in a header file (.hpp):
I have a c++ header file containing a class. I want to use this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.