Link to home
Start Free TrialLog in
Avatar of tmaga
tmaga

asked on

Transferring a variable between html pages

I am creating a product CD which is written in HTML.  There is a page where the users can click on the name of a AutoCAD drawing detail (out of about 2000 details to choose from) - [called the index page] and then the detail is displayed for them (courtesy of a plugin from AutoDesk called Volo View) - [called the display page].

My question is:  Is it possible to write only one display page and transfer the name of the file to display from the index page to the display page (thus avoiding writing about 2000 individual display pages which only vary in the filename to display)?

Please let me know if this is possible and include the source code if you can.

Thanks.
Avatar of y2kwacko
y2kwacko

Check out https://www.experts-exchange.com/jsp/qShow.jsp?ta=javascript&qid=10332674  - its still open and has a partial solution to your problem once you have that should be as easy as pie to finish.

Good Luck,
Kevin
You can save the name of the file in the index page:

<SCRIPT>
var sFile = "";
function file_name(cFile){
 sFile = cFile;
 }
</SCRIPT>

<A onclick="file_name('file.htm')" target="display" href="display.htm">file_name</a>


And in the display page get the name of the variable in the onload event:

<SCRIPT>
var sFile = "";
function window_onload(){
 window.alert(window.opener.sFile); //If it is other window
 window.alert (top.frames['index'].sFile); //If it is a frame
 }
</SCRIPT>

<BODY onload="window_onload()">


Manolo
Sorry, I wanted to make a comment
UHM, if they are like all images, you could try something like:

<html>
<body>
<script language=javascript>
<!--
   if(location.search)
      document.write("<img src=' + location.search + '><br>");

//-->
</script>

<a href='thispage.html?firstimage.jpg'>First Detail here</a>

</body>
</html>

Some explanation. The script'll take a look at the querystring (after the ? sign). If the querystring contains nothing, it won't show any image. If there IS something, then it'll write out the image (the part after ?). And after the image comes all the links again.
In the example, the page is called thispage.html. And the querystring is firstimage.jpg. If you open it first, then you won't see any image, but you will once you click on the link, cuz then there's something in the querystring.

Hope this does what you want.
little mistake there

document.write("<img src=' + location.search + '><br>");
should be
document.write("<img src='" + location.search + "'><br>");
Avatar of tmaga

ASKER

Sorry about the massive delay in responding, the day after I posted the question, I was unavoidably detained from using the computer.

I'm back and will see if the coding you have supplied will work and then (hopefully) award the points with no more delay.

Again, sorry for leaving this open for so long.
Avatar of tmaga

ASKER

This question has a deletion request Pending
This question no longer is pending deletion
..and why a deletion then?
Avatar of tmaga

ASKER

The company decided to elimate this type of indexing system on the CD.  I have no idea if what you had given me would even work.  

Do you want the Expert Points for your responses?  I have no problem with that, but first I will want to see if it works (can't give away something for nothing - even if it's only an academic challenge in the end).

I'll let you know my comments (as soon as I have any).  I hope that I didn't offend you (or ManoloMA for that matter) by attempting to delete the question.
tmaga, well I don't care about the points, but I just wanted to know the why of it. It'd be nice to have the points but not necessary.

And, to be honest, it sounds more than natural that if a question is answered you should at least evaluate the answers, that'd be appreciated.

Sorry for bothering you about that.

Regards,
CJ
Avatar of tmaga

ASKER

Definitely the considerate thing to do would be to provide feedback.  Sorry!  I know that... just under a little stress because now I've got to come up with the solution to the new way of doing things for the CD (the deadline hasn't changed...).

Best I can do is evaluate your proposed solution and give you feedback and the points.

No need to be sorry about informing me of my impoliteness.  Totally understandable and I would do the same thing in your place.

Best Regards,
Trevor
ASKER CERTIFIED SOLUTION
Avatar of CJ_S
CJ_S
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of tmaga

ASKER

Pardon?  I don't understand your last comment at all.
Avatar of tmaga

ASKER

Comment accepted as answer