?
Solved

Put a javascript variable value into a concatenated string

Posted on 2009-05-19
7
Medium Priority
?
546 Views
Last Modified: 2012-05-07
I am creating a chart on the fly with xml/swf charts. The problem that I am having is that I am passing a querystring value so that it knows what xml file to pull the data into the chart.

I have setup my javascript to grab my only query string variable, and it does this correctly (tested that it's getting the value with document.write). The problem that I have is when I have added the value into the concatenated string (line that starts with "library") it doesn't pull the value.

What am I missing?

Thanks!
<script language="JavaScript" type="text/javascript">
    
        <!--
 
        fullURL = location.search
        qs = fullURL.substring(fullURL.indexOf('?') + 1, fullURL.length)
        userId = qs.substring(qs.indexOf('=') + 1, qs.length)
                
        
        if (AC_FL_RunContent == 0 || DetectFlashVer == 0) {
            alert("This page requires AC_RunActiveContent.js.");
        } else {
            var hasRightVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
            if (hasRightVersion) {
                AC_FL_RunContent(
			'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,45,0',
			'width', '400',
			'height', '250',
			'scale', 'noscale',
			'salign', 'TL',
			'bgcolor', '#BE8407',
			'wmode', 'opaque',
			'movie', 'charts',
			'src', 'charts',
			'FlashVars',
			'library_path=charts_library&xml_source=' + userId + '.xml',
			'id', 'my_chart',
			'name', 'my_chart',
			'menu', 'true',
			'allowFullScreen', 'true',
			'allowScriptAccess', 'sameDomain',
			'quality', 'high',
			'align', 'middle',
			'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
			'play', 'true',
			'devicefont', 'false'
			);
            } else {
                var alternateContent = 'This content requires the Adobe Flash Player. '
		+ '<u><a href=http://www.macromedia.com/go/getflash/>Get Flash</a></u>.';
                document.write(alternateContent);
            }
        }
        // -->
        </script>

Open in new window

0
Comment
Question by:jrmcintosh
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 40

Expert Comment

by:Richard Quadling
ID: 24427029
Can you add ...

alert('library_path=charts_library&xml_source=' + userId + '.xml');

after the line that populates the userID variable.


0
 

Author Comment

by:jrmcintosh
ID: 24427071
What does that accomplish vs. what I have already tested with document.write.

Yes that gives me the correct URL value in the alert, but I need to place that userid below in the AC_FL_RunContent function.

Thanks for your help.
0
 
LVL 40

Expert Comment

by:Richard Quadling
ID: 24427135
I want to make sure that the alert shows the correct value.

What I want to make sure it that there are no spaces or additional characters.

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:jrmcintosh
ID: 24427416
Yes, there are no spaces or additional characters.

When I view source the line in question doesn't give the userID value, it shows the code exactly as it is, like this:

'library_path=charts_library&xml_source=' + userId + '.xml',

but I want it to look like this based on the variable value:

'library_path=charts_library&xml_source='1.xml',
0
 

Author Comment

by:jrmcintosh
ID: 24430030
Anyone?
0
 
LVL 40

Expert Comment

by:Richard Quadling
ID: 24430835
I assume ...

'library_path=charts_library&xml_source='1.xml',

should be ...

'library_path=charts_library&xml_source=1.xml',

Note the single quote before the ID.


The way I see this, the code is right.

I would now do some debugging in AC_FL_RunContent() to see what it is getting for param#20 (I assume the value associated with FlashVars).


0
 
LVL 40

Accepted Solution

by:
Richard Quadling earned 2000 total points
ID: 24430846
You won't see a change in the source. The code is processed at runtime, so something like FireBug or just dumb alerts(); are needed to see what is going on.
0

Featured Post

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

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

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.
Suggested Courses

771 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