Hi Diva. Thanks for your response.
However, I have been playing with the code that I have and have had a measure of success. I can now dynamically populate all of the dropdown from txt files. The coding is crude and could be better I am sure but it does work. My problem is that I need my last option to link to a product page and this doesn't happen. I am using onchange to achieve this but it will not work for some reason.
My coding is as follows -
index.html:
Code:
<!DOCTYPE html>
<head>
<meta charset='UTF-8'>
<title>Dynamic Dropdown</title>
<link rel='stylesheet' href='css/style.css'>
<script src="js/jquery.min.js">
</script>
<script>
$(function()
{
$("#manufacturer").change(function()
{
$("#type").load("textdata/type/" + $(this).val() + ".txt");
});
});
</script>
</head>
<body>
<div id="page-wrap">
<h1>Pulls from text files</h1>
<select id="manufacturer">
<option selected value="base">Please Select</option>
<option value="brother_type">Brother</option>
<option value="canon_type">Canon</option>
<option value="epson_type">Epson</option>
<option value="hp_type">Hewlett Packard</option>
</select>
<br />
<select id="type">
<option>Please choose from above</option>
</select>
<br />
<select id="series">
<option>Please choose from above</option>
</select>
<br />
<select id="models">
<option>Please choose from above</option>
</select>
</div>
</body>
</html>
This has populated the first box and links to the data from the text to gives options for the second one. Next I need to populate the third from another text file -
textdata/type/brother_type.txt:
Code:
<head>
<script>
$(function()
{
$("#type").change(function()
{
$("#series").load("textdata/series/" + $(this).val() + ".txt");
});
});
</script>
</head>
<option selected value="base">Please Select</option>
<option value="brother_toner">Brother Toner Cartridges</option>
<option value="brother_ink">Brother Ink Cartridges</option>
Now to populate the next box -
textdata/series/brother_ink.txt:
Code:
<head>
<script>
$(function()
{
$("#series").change(function()
{
$("#models").load("textdata/models/brother/ink/" + $(this).val() + ".txt");
});
});
</script>
</head>
<option selected value="base">Please Select</option>
<option value="dcp1">Brother DCP 1</option>
<option value="dcp2">Brother DCP 2</option>
Now to populate and link to my product -
textdata/models/brother/ink/dcp1.txt:
Code:
<select onchange="if (this.value) window.location.href=this.value">
<option selected value="base">Please Select</option>
<option value="www.yahoo.co.uk">Brother DCP test 1</option>
<option value="www.google.co.uk">Brother DCP test 2</option>
</select>
Unfortunately the onchange is not working and no link is made to the page that I am trying to get to. It basically does nothing from here.
The onchange code works on my current site with no issues and links automatically to my selected product when the option is chosen. I am not sure why this won't work and I have tried variations of this found on other coding websites but nothing I have tried has worked so far.
I know most would say as you have Diva, to go get help (and believe me a Psychiatrist probably would be useful), but I want to make a plugin for others to be able to download this or at least get the solution and update this thread so that others can use it if it helps them. I will still need to get to grips with styling this but I would like to get the functionality to it first. The css that is linked in the index page is only basic positioning on the page and nothing worthy of pasting into this thread.
Thanks again for your suggestion Diva but I do hope that someone has a solution to this issue as I know it could be of help to many people and a useful contribution to the Zen Cart community.
I look forward to any help that anyone can give and thanks again in advance.
Bookmarks