?
Solved

dynamic data in tree applet

Posted on 1999-10-29
8
Medium Priority
?
257 Views
Last Modified: 2013-12-25
I've got a tree applet wich I would like to use to display a database. The Database is diplaying but I can write a link to the attribute.

<param name=item1 value=dimension/specifier;;href;>

I need to write a href to the the param tag above. The href value is generated by runtime.

I'm working with Cache Weblink. Cache generates the href attribute by runtime. But it only generates them in a <a> or a <input type=SUBMIT> tag. I now need to read the href attribute from a link tag to insert it in the above shown code. how can this be achieved with javascript.
0
Comment
Question by:bickel
  • 5
  • 3
8 Comments
 
LVL 5

Accepted Solution

by:
aarie earned 400 total points
ID: 2168316
Try something like this...

----

<html>
<head>
<script language="javascript">
function GetUrl()
{
 return document.anchors[0].name;
}
</script>
</head>
<body>
<a name="MyUrl.html" href="MyUrl.html">tsjakka</a>
<br>
<script language="javascript">
document.write("<param name=item1 value=dimension/specifier;;" + GetUrl() + ";>");
</script>
</body>
</html>

------

I tested this in ns4.5 and ie5... It should work... The key here is the name attribute of the <A> tag...
if you make sure the value in the name attribute is the same as the value in the href attribute (see example, MyUrl.html), you should be okay... however, this code requires the link to be placed as the first <a> on the page...
if you can get Cache to generate the <a> tag like in my example, all should be working just fine... paste the script in the body at the location where the <param ... > should be placed.

getting the length of the anchors array can be done like so: document.anchors.length

however, this will ONLY return the number of <a>'s that have a name attribute set!!

or see http://msdn.microsoft.com/workshop/c-frame.htm#/workshop/author/dhtml/reference/objects/A.asp
for more info on this...


Arjan.
0
 
LVL 5

Expert Comment

by:aarie
ID: 2168318
BTW, IE won't show you the result when you use view source... netscape will.. ie will execute the code though...

Arjan.
0
 

Author Comment

by:bickel
ID: 2169341
I'll have to have different numbers by item1 anyway so I think looping the whole thing would be the best thing to do. Since a have almost no x-perince in Javascript I would like to ask you to maybe make a example with a loop. Thanks
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
LVL 5

Expert Comment

by:aarie
ID: 2172637
so there would be multiple parameters?? something looking like this?

<param name=item1 value=...>
<param name=item2 value=...>
....
<param name=item_n value=..>

where n would be the number of parameters...

You could make use of a loop, but then, the names of the parameters would look like item1,item2,etc... The most important thing about the loop is that the values for each parameter don't differ to much... Cause when your list of parameters would look something like

<param name=item1 value="myUrl.html">
<param name=item2 value="Roy Rogers">

then a loop would be useless....

Could you show me what the list of parameters and values looks like (in html code)?? That would make it a lot easier for me to help you out...

Arjan.
0
 

Author Comment

by:bickel
ID: 2173528
My list of params looks like this:

<param name="item1" value="verb;;URL1;">
<param name="item2" value="verb/instance;;URL2;">
<param name="item3" value="noun;;URL3;">

I need to dynamically insert the numbers 1,2,3,4,5,6... The place in the tree (verb, verb/instance, noun, ...) and the URLS (URL1,URL2,URL3). These URLs are generated when the page is looked at. The rest is generated when I compile, but I think it would be easyest to write it to the params the when writing the URLs.

Thanks

Lucas
0
 
LVL 5

Expert Comment

by:aarie
ID: 2181117
Assuming once again that the url's are allready on the page, with preset names, say "MyUrl1","MyUrl2",..,"MyUrln"
where n is the total number of parameters which need an url in the value part.

---
<head>
....
<script language="javascript">
function GetUrl(Number)
{
 return document.anchors[Number].name;
}

ParamNamesString = "ParName1,ParName2,..,ParNamen";
ParamNames = ParamNamesString.split(",");

FixedValPartsStr = "Val1,Val2,...Valn";
FixedVal = FixedValParsStr.split(",");
</script>
....
</head>
<body>
<a href="MyUrl1" name="MyUrl1"></a>
....
<a href="MyUrln" name="MyUrln"></a>
.....
<script language="javascript">
for(i=0; i < FixedVal.length;i++)
  {
   tmp = "<param name=\"" + ParamNames[i] + "\" value=\"" + FixedVal[i];
   if( i < document.anchors.length)
     tmp += GetUrl(i);

   tmp += "\">\n";

   document.write(tmp);
  } // end for i
</script>
</body>

---------------------

Here's what you need to do to make it work...

1. Place the names of your parameters in the ParamNamesString variable, separated by commas (like above).
2. Place the fixed parts of your value parts in the FixedValPartsStr variable like with the parameters. Make sure that all parameters that require a Url come first!!
3. Have Cache generate the url's like above, including the name attribute...

That should do the trick...
If you have any problems with it let me know...

Arjan.
0
 
LVL 5

Expert Comment

by:aarie
ID: 2196475
Did my proposed solution work?

Arjan.
0
 

Author Comment

by:bickel
ID: 2202406
I didn't try yet because the Java-tree became a lower priority in my project.

If you can wait another 1-2 weeks i'll try and you'll get the points.

thanks
 
0

Featured Post

[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Originally, this post was published on Monitis Blog, you can check it here . It goes without saying that technology has transformed society and the very nature of how we live, work, and communicate in ways that would’ve been incomprehensible 5 ye…
There is a wide range of advantages associated with the use of ASP.NET. This is why this programming framework is used to create excellent enterprise-class websites, technologies, and web applications.
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.
Suggested Courses
Course of the Month4 days, 21 hours left to enroll

601 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question