Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Blackout
Jun 29, 2005

I am a deathdealer.
Hey guys, quick question. I'm trying to write a very simple piece of javascript that does two things. First, it will either show or hide an HTML div with the first id I specify. Second, it will change the text of the div with the second id specified. It should toggle these things, so if the div is shown, it will be hidden and vice versa. Same thing with the text (switches between 'Show...' and 'Hide').

Thing is, I'm doing this through an xsl stylesheet. I've got a separate javascript file that the stylesheet references. I've used my javascript functions elsewhere in the stylesheet and they work fine, but in this instance, I'm using xml attributes as ids for the divs, and I'm getting weird results. In IE, the text will toggle just fine, but the div won't disappear/reappear. In Firefox, the show/hide works but the text will only toggle once.

Here is the java script:

code:
function togglePage(objID) {
if (!document.getElementById) return;
var ob = document.getElementById(objID).style;
ob.display = (ob.display == 'none')?'block': 'none';
}

function togglePageAndText(objID, objID2) {
togglePage(objID);
document.getElementById(objID2).innerHTML = (document.getElementById(objID2).innerHTML == 'Show...')?'Hide' : 'Show...';
}
And here is the xsl:

code:
<div id="{@FunctionalArea}" onclick="togglePageAndText('{@FunctionalArea}_testCases', '{@FunctionalArea}')">Show...</div>
<div id="{@FunctionalArea}_testCases">
    <xsl:call-template name="DetailTestCases"/>
</div>
Any ideas?

Thanks!

Adbot
ADBOT LOVES YOU

Blackout
Jun 29, 2005

I am a deathdealer.
Hi guys, quick question for you. I've got a whole bunch of xml files which use a stylesheet to be displayed as HTML. The files are organized by folder on my computer, so that the structure looks something like this:

Main Folder
--Folder A
----1.xml
----2.xml
----3.xml
--Folder B
----4.xml
----5.xml
--Folder C
----6.xml
----7.xml

The number of files in each folder as well as the number of folders themselves can change, so I'd like to try and dynamically build a link tree. Using javascript to create the tree and the links is easy enough, but I'm stuck trying to figure out how to grab the names of these files/folders. I've found a bunch of stuff about the Scripting.FileSystemObject ActiveX object, but it seems to be pretty useless because of the security constraints and the fact that Firefox doesn't seem to support it. Do any of you know of any other methods I could use to list all of the files and folders residing under the Main Folder?

Thanks in advance!

Blackout fucked around with this message at 23:40 on May 6, 2009

Blackout
Jun 29, 2005

I am a deathdealer.

jupo posted:

Gonna assume you're talking about javascript in the browser since you mentioned Firefox. What you're trying to do here is traditionally a server-side thing with languages like PHP or ASP, and not done in the browser. If you're hosting your site on IIS then you are actually able to write ASP code using javascript and the FileSystemObject but this all runs on the server and security constraints aren't relevant here.

If you have no sever-side programming ability and you're a true masochist you could potentially try and do something that uses ajax to parse directory listing pages on the server and build the tree from that, but don't.

Thanks for the advice, jupo! I guess I'll try to use IIS to do some server-side scripting with ASP or something.

Blackout
Jun 29, 2005

I am a deathdealer.
Hey, I'm back again with another question!

I managed to solve the problem I was having earlier using ASP (dynamically creating a bunch of links based on files/folders).

Now, I'm trying to create a summary section for each of the groups of files.

I've got an asp file which creates all of my links, and inside that same file, I've got a function that will create html and return it in a string. This asp file is located in one frame, and I have a target frame next to it. I'm trying to figure out a way to create a link that will, rather than displaying another page in the target frame, call this function and display the html that comes back in the target frame.

So basically, when I click link A, I want it to call function B and show what the function returns in frame C.

Hopefully thats not confusing...

Thanks!

Blackout
Jun 29, 2005

I am a deathdealer.

Lumpy posted:

code:
<a href="blah.asp" target="framename">my link</a>

That would be really easy, but my situation is a bit different. I've got my function in blah.asp, but I want to call it in multiple spots, passing different parameters. The HTML that the function returns is what I want to create a link to, not the asp page itself.

Lets say I have the following page where each xml is a link:

Header A
- 1.xml
- 2.xml
Header B
- 3.xml
- 4.xml

For each of the headers, I want to call this function in blah.asp, which will return html for a page containing a summary of stats for the xmls under the given header. I then want to create a link under the header that, when clicked, will display that HTML in my target frame.

So its a bit more complicated than putting an asp file in a link...

Adbot
ADBOT LOVES YOU

Blackout
Jun 29, 2005

I am a deathdealer.

Lumpy posted:

So you want a link under each header, then when clicked, runs blah.asp but produces different HTML based on which header link you clicked:

code:
<a href="blah.asp?header=a" target="framename">header A link</a>
...
<a href="blah.asp?header=b" target="framename">header B link</a>
Unless I'm completely missing what you are asking. Sorry for the non-javascript stuff rest of thread :(

Yeah, I apologize for the de-rail too, but I couldn't find an asp thread!
Thanks alot for the help Lumpy! As you can tell, I'm pretty new to this, so I really appreciate it!

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply