Jump to content

Parameter for <script> tag


kurt.santo

Recommended Posts

On product pages of a friend's website we have to include script tags as the following

<script src='http://shopping.netsuite.com/app/site/query/getitemname.nl?c=123&n=1&id=36'></script>

in order to pull the relevant content from his backend (Netsuite).As the bit before 36 (in this case the id for the relevant product) is the same for all products' image names, I would like to pass the relevant id's from the nav bar. How would I do this? Can I just append a "?36" to the URL? How would I add the passed parameter to the script?Can this be done with PHP? That would be great!Kurt

Link to comment
Share on other sites

I'm confused about what you're asking.

I would like to pass the relevant id's from the nav bar. How would I do this? Can I just append a "?36" to the URL?
Yeah, I guess you can type whatever you want in the URL. Querystring values are key/value pairs. If you do ?36 you are saying that the variable is called "36" and it has no value. Doing ?id=36 says that the variable is called "id" and the value is "36".
How would I add the passed parameter to the script?
What script? What are you using to add it? With PHP you can reference a variable called "id" that was sent in the querystring using $_GET['id'].If that doesn't answer your question try to clarify the question a little more.
Link to comment
Share on other sites

I'm confused about what you're asking. Yeah, I guess you can type whatever you want in the URL. Querystring values are key/value pairs. If you do ?36 you are saying that the variable is called "36" and it has no value. Doing ?id=36 says that the variable is called "id" and the value is "36".What script? What are you using to add it? With PHP you can reference a variable called "id" that was sent in the querystring using $_GET['id'].If that doesn't answer your question try to clarify the question a little more.
My friend's site has to use scripts, which are used to pull information from his backend database. We have to use the scripts as they are, they are given per item (with script for name, description, price and and and). You simply put them whereever you need them (there is nothing in the header or so) and it pulls the relevant info into the page. One example is
<script src='http://shopping.netsuite.com/app/site/query/getitemldescr.nl?c=448585&n=1&id=36'></script>

When you place that code into an HTML page is gets the item description for the item with id=36. This is the only way to get the info into a website.As my friend has a lot of products I did not want to produce a page per product and thought I could just somehow pass parameters from the nav bar to get the right product details in our product page. So, as far as I understood I would need to have for the product with the id of 36 a link in the nav bar, which is sth like "products.php?id=36" (for the other ones "products.php?id=whatever id is"), but how do I add this to "http://shopping.netsuite.com/app/site/query/getitemldescr.nl?c=448585&n=1&TooAdd"></script>It would be great if you could let me know how to append the "id=36" bit to the script...I hope I made myself clearer.KurtForgot: the scripts are the same for each product. It is just the bit "id=36", which changes...

Link to comment
Share on other sites

<script src='http://shopping.netsuite.com/app/site/query/getitemldescr.nl?c=448585&n=1&id=<?php echo $_GET['id']; ?>'></script>
You are my hero, what a great day! Cheers, mate. Works well. One more question for now (might come up with 1000 more as I still have to figure out how to make sections visible/invisible and highlight the active button): I enter then for each menu item the complete link including relevant id? Or is there a shortcut to specify the product.php file for each menu item globally (if I can say so in this contect) and just have the id/value pair for each menu item? Do not worry, I am just curious...Kurt
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...