PDA

View Full Version : Some help on passing a parameter in text HTML(javascript)?



ismailc
01-10-2008, 08:48 AM
Hi, I need help please

I usually code in coldfusion but now i want to create 2 text html files where i
pass a parameter on href?

This normally works in coldfusion!

Page1
<a href="test.htm?test=100','','height=300,width=300">

Page2
<html>
<head>
<param name="test" value=""/>
</head>
<body>
<cfoutput>
#test#
</cfoutput>
</body>
</html>

It displays #test# but in the url i can see the value it's passing but the second
page does not pick it up!

Assist"Without some kind of server-side processing (PHP, ColdFusion, etc.) or
some fancy JavaScript, you aren't going to be able to display a URL
variable. Raw HTML can't do that"

Does anyone have an example of some javascript/ or other that can do it?

Regards

codeexploiter
01-10-2008, 09:33 AM
You can pass a parameter(s) from one HTML page to another HTML page and witout using any server-side processing at all you can retrieve the value using the client-side JavaScript. Please check the following link in which different methods are described to do the value passing between pages.

http://www.cryer.co.uk/resources/javascript/script8.htm

ismailc
01-10-2008, 11:37 AM
Hi, Thank You for the assist!

I tried the following, it opens the page with the text box but does not pass/insert the value!
The url has the value but it does not insert it: file:///C:/test/test/jquery-tooltip/ajax.htm?Something=100

Please Assist!

Page1: <A HREF='ajax.htm?Something=100'>Click here</A>

Page2: <form action="ajax.htm">
<script type="text/javascript">
function GetParam(name)
{
var start=location.search.indexOf("?"+name+"=");
if (start<0) start=location.search.indexOf("&"+name+"=");
if (start<0) return '';
start += name.length+2;
var end=location.search.indexOf("&",start)-1;
if (end<0) end=location.search.length;
var result='';
for(var i=start;i<=end;i++) {
var c=location.search.charAt(i);
result=result+(c=='+'?' ':c);
}
return unescape(result);
}
</script>

<input type="text" name="Something">
</form>

jscheuer1
01-10-2008, 04:42 PM
Using my own version of the code that gets the value, and adding code to actually use this for the field name:


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
;(function(){
var field='Something', //set the name of the field
getQval = function (n) {
var r=new RegExp('[?&;]'+n+'=([^&;#]*)'), m=location.search;
return (m=r.exec(m))? unescape(m[1]) : null;
}, updateForm = function() {
var fname=getQval('fname')? getQval('fname') : 0;
document.forms[fname].elements[field].value=val;
}, val=getQval(field);
if(val){
if ( typeof window.addEventListener != "undefined" )
window.addEventListener( "load", updateForm, false );
else if ( typeof window.attachEvent != "undefined" )
window.attachEvent( "onload", updateForm );
else {
if ( window.onload != null ) {
var oldOnload = window.onload;
window.onload = function ( e ) {
oldOnload( e );
updateForm();
};}
else window.onload = updateForm;}}})();
</script>
</head>
<body>
<form action="ajax.htm">
<div>
<input type="text" name="Something">
</div>
</form>
</body>
</html>

ismailc
01-11-2008, 07:31 AM
Hi: Thank You very much but the idea did not come off as what i thought!

I downloaded this example: Dowlod this example - very small file!http://www.codylindley.com/blogstuff/js/jtip/
from the net to fix the problem i have with my projects tooltip. We use the 'ALT' on a image to give tooltips so I download a workaround from the net - which works but it displays typed text pages.
so if i had 5 fields with tooltips - i would have to create 5 html pages. So i thought of passing a parameter like you assisted but the tooltip does not picki t up.

Your example works great on page1 to page2
but not on the below code: on mouse over it shows the next page with text box but blank-no value - but if I open i new window then the value is there!

Please download the example - i'm not to sure how to fix this!

<html>
<body>
This works: <A HREF='ajax.htm?Something=test'>Click here</A>

Example from Net does not like it
<style type='text/css' media='all'>@import 'css/global.css';</style>
<script src='js/jquery.js' type='text/javascript'></script>
<script src='js/jtip.js' type='text/javascript'></script>
<tr>
<td colspan="10" align="center">
<a id="one" href="ajax.htm?Something=test" class="jTip">?</a>
</td>
</tr>


</body>

</html>

jscheuer1
01-11-2008, 07:59 AM
I have some extra stuff in the page for date and time, but here is a demo - try it first with no query being passed:

http://home.comcast.net/~jscheuer1/side/receiver.htm

then with one:

http://home.comcast.net/~jscheuer1/side/receiver.htm?Something=Bob

ismailc
01-11-2008, 08:53 AM
Hi,

Thanx but this does not fix my problem as in my previous post

Regards

jscheuer1
01-11-2008, 09:05 AM
Please edit your message (the one with the links in it) or rewrite it as a new message, the links are broken and you haven't explained the problem very well. Please fix the links and make the explanation of the problem clearer.

ismailc
01-11-2008, 09:24 AM
Thank You very much & i'm really gratefull for the help - Please Assist as i need to get this working.

I downloaded this example (workaround) from the net - small file!

http://www.codylindley.com/blogstuff/js/jtip/

Download the files/demo from the link: Download this example

To fix the problem i have with my project's tooltip.
We use the 'ALT' on a image to give tooltips so I download a workaround from the net - which works but it displays html text pages fine.
so if i had 5 fields with tooltips - i would have to create 5 html pages ( i have about 40). So i thought of passing a parameter like you assisted but the tooltip does not pick it up.

On the example on the link onmouseover ? it displays another page with text, my idea is to pass a parameter with the text I want on one page rather than 40 pages!

Your example works great on page1 to page2
but not on the below code: onmouseover it shows the next page with text box but no value - but if I open i new window then the value is there!

Please download the example (the js files are needed)- i'm not to sure how to fix this!

<html>
<body>
This works:<A HREF='ajax.htm?Something=test'>Click here</A>

Example from Net (downloaded) does not like it
<style type='text/css' media='all'>@import 'css/global.css';</style>
<script src='js/jquery.js' type='text/javascript'></script>
<script src='js/jtip.js' type='text/javascript'></script>
<tr>
<td colspan="10" align="center">
<a id="one" href="ajax.htm?Something=test" class="jTip">?</a>
</td>
</tr>
</body>
</html>

jscheuer1
01-11-2008, 04:46 PM
Sounds to me as though you are going an awfully long way around to try adapting a script that is meant to work one way to work another. There are so many tool tip type scripts around, I'm sure that you could find one that doesn't require such a (possibly very involved) modification. The reason it might be so involved is that the script (jtip) already makes its own use of the query string for determining the width of the tip, and the javascript for receiving the query information on the tip content page will never work with jtip's Ajax, jtip would need to be almost completely rewritten.

Look here:

http://www.dynamicdrive.com/dynamicindex16/showhint.htm

if that isn't suitable, look at some of the many other tip scripts here:

http://www.dynamicdrive.com/dynamicindex5/index.html

However, no matter what you do, you will need to have tip content for each tip, so it might not be all that bad to just stick with what you are using. Does it really make that big of a difference where this content is stored? Whether it is on the page that uses it or on separate pages just doesn't seem like much of a difference to me. Being on separate pages allows for each tip to be used by several pages while each tip only needs to be edited at one location.

ismailc
01-14-2008, 10:56 AM
Hi, Thank You very, very much - really keeping me motivated in this project of mine. Really appreciate all your effort & help!

I'm coding in flowcentric whcih uses xslt file for it's stylesheet!

I'm busy with the : Rich HTML Balloon Tooltip

So now I'm trying to incorporate it my xslt file:

The problem i now have that it works, but i can't seem to loop or direct it to the proper value:
The tooltip displays the first value only for all the tooltips
Please, Please Assist!

<link rel="stylesheet" type="text/css" href="balloontip.css" />

<script type="text/javascript" src="balloontip.js"></script>


<xsl:if test="Tooltip != ''">

<!-- <xsl:element name="asp:image">
<img src="images/tooltip.gif"></img>
<xsl:attribute name='id'>ttip_<xsl:value-of select='@name' /></xsl:attribute>
<xsl:attribute name='runat'>server</xsl:attribute>
<xsl:attribute name='imageurl'>images/tooltip.gif</xsl:attribute>
<xsl:attribute name='alt'><xsl:value-of select="Tooltip" /></xsl:attribute>-->

<a>
<xsl:attribute name='href'>ajax.htm</xsl:attribute>
<xsl:attribute name='rel'>balloon1</xsl:attribute>??
</a>

<div id="balloon1" class="balloonstyle">
<xsl:value-of select="Tooltip" />
</div>

<!--</xsl:element>-->

</xsl:if>
</td>

[B]Thank You - if you know xslt - would you please Assist!

Another one of my to-do in the project is to:
a text box with image - onclick hide text box & display drop down or change text box to dropdown & on exit of drop down display text box with selected value - Any ideas Please?