Search DominoPower's 11,443 Lotus-related article archive 
Home
EasyPrint
News details Click here for the RSS feed's XML code. This is not a browser URL.
Articles-only Click here for the RSS feed's XML code. This is not a browser URL.
Twitter Feed Click here for the Twitter feed.
Using JavaScript to get the Query_String from a frameset (continued)

Here is how you can get a parameter using the above function:

var productNameLink = getParameter ( framesetQuery, 'productname' );

In my application, I put the code above in the JS Header. Later on, when I am actually assigning the value to a field, I reference this parameter in the onLoad event.

One key thing to remember here is that JavaScript is case-sensitive. Therefore, whenever I'm working with things like parameter names or frame names, I usually always try to make them all lower case in order to eliminate case-related problems.

Manipulating the result
Once you've gotten the value of a parameter from the Query_String you might need to manipulate it. For instance, in order to pass values containing spaces, you have to put plus signs where the spaces were so they will work in the URL. On my form, I've got two variables. The first is productNameLink. It is exactly equal to the parameter value, including plus signs. The second variable is called productName, and it's computed using the "replaceSubstring" JavaScript function below (which you should place in the JS Header section of your form) to replace the plus signs with spaces once again. As you'll see in the final section, when I'm writing code back to the browser, I'll need to use both of these variables.

function replaceSubstring ( inputString, badString, goodString, caseSensitive ) {
fixedReplace = " ";
UI = inputString;
UB = badString;
if ((caseSensitive !=1) && (caseSensitive != true)) {
UI = inputString.toUpperCase();
UB = badString.toUpperCase();
}
badEnd = -1;
badLoc = UI.indexOf(UB);
if (badLoc != -1) {
for (x=1; (badLoc != -1); x++) {
fixedReplace = fixedReplace + inputString.substring((badEnd + 1), badLoc) + goodString
badEnd = badLoc + UB.length - 1;
badLoc = UI.indexOf(UB, (badLoc + 1)); }
fixedReplace = fixedReplace + inputString.substring((badEnd + 1), inputString.length); }
else { fixedReplace = inputString; }
return fixedReplace;
}

You can then manipulate the value of the parameter in the JS Header with the following code:

var productName = replaceSubstring ( productNameLink, "+", " ", false);

Notice how I used the productNameLink variable I had already computed above and simply replaced the plus signs with spaces.

But wait, there's more! As a special bonus, I'm also going to include a JavaScript "trim" function that will help you to remove any extraneous leading or following spaces that you might have in a string:

function trim ( inputStringTrim ) {
fixedTrim = "";
lastCh = " ";
for (x=0; x < inputStringTrim.length; x++) {
ch = inputStringTrim.charAt(x);
if ((ch != " ") || (lastCh != " ")) { fixedTrim += ch; }
lastCh = ch;
}
if (fixedTrim.charAt(fixedTrim.length - 1) == " ") {
fixedTrim = fixedTrim.substring(0, fixedTrim.length - 1); }
return fixedTrim
}


« Previous  ·  1  ·  2  ·  3  ·  4  ·  5  ·  Next »
Other articles you might like
Home > Internet Technologies > JavaScript (13 articles)
   Sorting your Domino views with JavaScript
   Give your Domino views life with DHTML
   Using dynamically generated HTML to thwart spam email address harvesting
Get Weekly Email Updates
Subscribe to our regular weekly email newsletter. It's packed with tips, reviews, deep analysis, and the latest news.
 
Recent DominoPower Articles
Syncing Notes with Android phones
Application development, William Shatner, and the origin of the universe
Learn Domino Designer 8.5 for free
The (near) future of Sametime, Quickr, Connections, and Symphony
Inside the IBM Innovations lab
Lotusphere 2010: Hot fixes and cool news for Notes, Domino, and LotusLive
Lotusphere 2010: mobility and collaboration
Latest Lotus Headlines
Xpages not loading? JVM errors? - Solution
How to implement an iCalendar feed into your Notes calendar with XPages
DWA Hotfixes for Domino 8.5.1FP1 - A Gotcha
IBM Adds DB2 to Lotus Foundations SMB Package
SNTT : XPages onclick Ghosts in the machine
Ports used by Lotus Sametime 8.5 servers
Exploring a Domino Date Bug
>> Read all the news
More from the ZATZ journals
Computing Unplugged: Online safety for virtual learning
David Gewirtz Online: CNN commentary and analysis
OutlookPower: Seek and find: Strategies to locate filed-away emails fast
-- Advertisement --

Sophisticated Meets Simple For Document Management
Share. Control. Manage.
Documents, emails, and content in the context of how work is done. Native to Lotus Domino. The User Experience unseen for Lotus Domino. Do more with less. Really.

See the possibilities Docova unleashes for Lotus Domino.
-- Advertisement --

Mark your calendar for in-depth Lotus training, May 12-14, Boston
Join experts and peers May 12-14 in Boston for educational and networking events that deliver real-world Lotus training so you can increase productivity and efficiency in your company, advance your skills, and squeeze the most from your current environment. One registration gets you into THE VIEW's Admin2010 and Lotus Developer2010.

Register by April 10 to save $200.
ZATZ Home  ·  News  ·  Back Issues  ·  Credits/Trademarks ·  Link To Us
Copyright © 1998-2010, ZATZ Publishing. All rights reserved worldwide.
Editor's Login