Python - passing two arguments to two different pages using url get method

I have a table which  lists members by memberID. Clicking on a memberID link sends the memberID value and the name of the member to a  target page orderformtwo.CGI. This works, no problem and the relevant piece of code is shown below.

print('<td><a href="orderformtwo.CGI?memberID={memberID}">{member_name}</a></td>'.format(memberID=each[0], member_name=each[2]))

I need to modify (if possible) this so that clicking on a memberID link sends the information (memberID and name) to an additional target page otherpage.cgi.  Its not clear to me how I can modify the above code to accomplish this - even if it is possible.

Thanks for your help
jameskaneAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

gelonidaCommented:
The answer is a little difficult and depends quite a lot on what these cgi scripts are doing, in which language they're written and whether they're hosted on the same server.
and which output the user should see on the browser. (The output of the first or of the second cgi script)

Therefore I won't provide you with a solution, but 'only' with some basic ideas.

There's a few different approaches to this problem, for example:
1.) refactor your two cgi scripts. if both cgi scipts are written in python and on the same server
2.)  enhance your orderformtwo.CGI to 'call aotherscript.cgi server side
3.) use javascript on your web page


1.) Refactoring your cgi code (both python.cgi):
--------------------------------------------------------------------------------
The first approach assumes, that you have control of
otherpage.cgi and of orderformtwo.CGI
I assume both cgi scripts are on the same server and both are written in python?
Is this assumption true?
If not, then look at the next approach.

rewrite otherscript.cgi such, that that it's main functionality (without creating any output) is in an independent function and in a separate python file.
now both cgi scripts can import the functionality and use it.

2.)  enhance your orderformtwo.CGI with server side call
-------------------------------------------------------------------------------------
if both scripts are hosted on the same server, then you
orderformtwo.CGI could use subprocess.popen (with stdout, stderr being redirtected)
and just call otherpage.cgi

3.) solve the problem in javascript
----------------------------------------------------
This solution is a non python solution and is purely implemented browser side with javascript.

the web browser will call a javascript function, when the link is clicked and the called function will do whatever you'd like to do.
it can perform the two requests.

You should be able to call a javascript when linking on an a tag with folowoign syntax:
print('<td><a href="javascript:my_function({memberID})">{member_name}</a></td>'.format(memberID=each[0], member_name=each[2]))

Open in new window


Now you have to decide exactly what your javascript function that you have to declare should do:

Please note, that the complexity of the javascript solution depends on which browsers you have to support and whether you're willing to use javascript libraries like for example jquery.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jameskaneAuthor Commented:
Many thanks for the thoughtful reply gelonida !

My set up is as follows :

* Everything written in python
* One server only  -  Apache
* Using mysql
* Using firefox as a platform for presenting the application (pages accessible via Tabs.
* Nature of application - order entry and processing -  check mgmt, mgmt reporting.  Screens are essentially forms and tables of mgmt reports.
*  The application runs standalone on a pc and order is entered via conversation between member and order entry person. I would like in the future to consider two order entry points, connected to the server on a third PC.

Given above, your solution set 1 (refactoring) would seem to be best - although I am very comfortable using jquery. I am trying to leverage the browser functionality of Firefox in presenting the application - eg 4 or 5 tabs open to provide access to the different sections of the application - all synced on the current memberID in use.

I take it from your input that is not possible to tweek the url get method as per code clip I sent you. I was hoping it was just a syntax problem at my end. You are ruling that out as a solution ?

many thanks again
0
gelonidaCommented:
I take it from your input that is not possible to tweek the url get method as per code clip I sent you. I was hoping it was just a syntax problem at my end. You are ruling that out as a solution ?

I'm  rather sure, that there's no way to perform 2 posts / two gets from one <A> tag, except using javascript.

In any case if you had two get requests you had to decide which of the two get results should be result to be used for displaying the new web contents.
0
jameskaneAuthor Commented:
many thanks - for the direction and the education. Problem solved !
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Python

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.