Retrieving variable from URL


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: Retrieving variable from URL

  1. #1
    Join Date
    Jun 2006
    Posts
    23

    Delete me

    I can't get this to work. I grabs the variable after the "?" and leaves out any "%" or "2" or "0". There are only 13 department names going to be passed through, so I don't need to wory about #'s.

    It did work in FF until I tried to add browser compatability since it has to be IE and FF compliant. I am confused why this does not work. Thanks for your time.


    if (document.getElementById)
    {var strvar = document.getElementById("url").indexOf('?');}
    else
    {var strvar = document.url.indexOf('?');}


    if (strvar != -1)
    {
    if (document.getElementById)
    {strsearch = document.getElementById("url").substring(strvar+1, document.getElementById("url").length);}
    else
    {strsearch = document.url.substring(strvar+1, document.url.length);}

    for (count = 0; count < strsearch.length; count++)

    {

    if (strsearch.charAt(count) == "%")
    {document.write (" ");}

    else if (strsearch.charAt(count) == "2")
    {document.write (" ");}

    else if (strsearch.charAt(count) == "0")
    {document.write (" ");}

    else

    {document.write (strsearch.charAt(count));}

    }
    }


    else
    {document.write("No Department Selected");}
    Last edited by buma; 07-05-2006 at 04:26 PM.

  2. #2
    Join Date
    Jun 2006
    Posts
    23
    bump. I don't think this is too complicated of a problem for someone how is smarter in DOM's

  3. #3
    Join Date
    Oct 2004
    Posts
    311
    you're talking javascript here. This is a Java forum, perhaps you would get more responses if you asked in the right forum

  4. #4
    Join Date
    Jun 2006
    Posts
    23
    moved, ok'd to delete this one. thx ractoc

Similar Threads

  1. How to retain session variable
    By NikhilSriv in forum Java
    Replies: 1
    Last Post: 06-14-2006, 05:24 AM
  2. Encypting a URL
    By John Butler in forum ASP.NET
    Replies: 0
    Last Post: 11-26-2002, 03:53 PM
  3. Replies: 1
    Last Post: 11-28-2001, 03:43 AM
  4. Caching the URL
    By gvt in forum VB Classic
    Replies: 0
    Last Post: 02-07-2001, 08:47 AM
  5. Caching the URL
    By gvt in forum VB Classic
    Replies: 0
    Last Post: 02-07-2001, 08:47 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center