I'm currently developing a web page that accesses a CGI string to query an application and return results to a page: http://empress-media.net/jimflynnrentals/gear_test.html

The CGI string is: http://servername/cgi-bin/nph-omniscgi?OmnisLibrary=tbsWeb&OmnisServer=5912&OmnisClass=rtPublicSearch&MethodName=search&SessionID=PUBLIC&bXML=1&bXMLData=0&SQLClassName=qCategoryLookup&SearchCriteriaString=STYPE_CATEGORY%2CNOT%20%25LIKE%25%2Cggg

It currently works to return the list of categories. It uses Javascript methods to return the results to a DIV on the page

function setDataHTML(xmlHttp)
{
document.getElementById('CollapsiblePanel2').lastChild.innerHTML = xmlHttp.responseText;
}

The problem is, I need each of those returned categories to be clickable since clicking on any of those categories, will result in a subquery to show specific product items within that category. I'm thinking PHP would be a better way to go since Javascript isn't great for passing variables into links.

Has anyone done anything similar to this and have code samples I can see?

Any help is greatly appreciated!!
Maile

Could you be a bit more clearer on what you want done because the description is a bit patchy. From what I can understand, you have a variable somewhere and you want to append it to the current url. I think the following php script would do that if the variable originated from the php side and not javascript.

$page=basename($_SERVER['REQUEST_URI']);
$page.='&newvar=true';
echo '<a href="'.$page.'">test</a>';

Hi there,

I am mainly trying to figure out if PHP or Javascript is the way to go for what I want to do. I have a page that in onLoad, calls a Perl script to perform a query and return the results on the page. Right now, Javascript returns the results to the page as static text in a list within a DIV.

What I need to do next is to make it so that users can click any of those static text results (Product Categories) to perform a query of items within that category. So, I will need to create variables to pass in with the URL. So far, what I'm reading indicates that it is better to format responseText with PHP rather than Javascript.

Thanks!
Maile

Then in that case the example I prevously posted will do the job but you will need to tell php what to place on the end of the link. Below are several more examples which will link to the same page but with an additional url parameter:

$page=basename($_SERVER['REQUEST_URI']);
$page.='&id=6438';
echo '<a href="'.$page.'">test</a>';
$page=basename($_SERVER['REQUEST_URI']);
$page.='&status=online';
echo '<a href="'.$page.'">test</a>';

And below will allow you to send the user to a different php file with the current url parameters:

$page=explode('?',basename($_SERVER['REQUEST_URI']));
$page=$page[1];
$page='filename.php?'.$page.'&id=6438';
echo '<a href="'.$page.'">test</a>';
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.