Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Some help on passing a parameter in text HTML(javascript)?

  1. #1
    Join Date
    Dec 2007
    Posts
    88
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Question Some help on passing a parameter in text HTML(javascript)?

    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

  2. #2
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    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

  3. #3
    Join Date
    Dec 2007
    Posts
    88
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Question Thank You but unfortunately still not working

    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>

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Using my own version of the code that gets the value, and adding code to actually use this for the field name:

    Code:
    <!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>
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Dec 2007
    Posts
    88
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Question Wow - Thank You very Much! I still need help

    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![
    URL="http://www.codylindley.com/blogstuff/js/jtip/"]http://www.codylindley.com/blogstuff/js/jtip/[/URL]
    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>

  6. #6
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    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/s...?Something=Bob
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  7. #7
    Join Date
    Dec 2007
    Posts
    88
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Thank You - but this does not fix my problem

    Hi,

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

    Regards

  8. #8
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    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.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  9. #9
    Join Date
    Dec 2007
    Posts
    88
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Question Please, Please Assist - i need this to work!

    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>

  10. #10
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    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.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •