Welcome to Dream.In.Code
Getting Help is Easy!

Join 109,154 Programmers for FREE! Ask your question and get quick answers from experts. There are 1,124 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



parse query string in href function?

 
Reply to this topicStart new topic

parse query string in href function?

Inny
post 18 Mar, 2008 - 03:49 AM
Post #1


New D.I.C Head

*
Joined: 18 Mar, 2008
Posts: 13



Thanked 4 times
My Contributions


Im trying to rewrite a link with a href function. I need to parse a query string within it ('+tid')

But all attempts Have falied. The current onclick/ link function

CODE
<a href="java script:who_posted();">Who Posted?</a>


is attached to my forums 'replys' number colum in forum veiw' {i have no direct access}

it appears in the staus bar on hover as

CODE
<a href="java script:who_posted(428);">Who Posted?</a>


where '428 is the tid (topic id).

I want to write a href link to do this (elsewhere in html) and add the tid of whatever topic
the page is currently on.

see site for clarification (click the 'replies' number next to a title)

http://inny.ipbfree.com/index.php?showforum=1

click on any topic, and see a mail href link above. I want to add the who_posted function href there, so that whatever topic your on, the who posted box will work.

code is {no direct access}

CODE
<script language='javascript' type="text/javascript">
<!--
    function who_posted(tid)
    {
        window.open("http://inny.ipbfree.com/index.php?s=&act=Stats&CODE=who&t="+tid, "WhoPosted", "toolbar=no,scrollbars=yes,resizable=yes,width=230,height=300");
    }
//-->
</script>



Im not sure to write the new link to include the extra function of adding the topic id (tid)

i tried a few variations on
CODE
<a href="java script:window.open("http://inny.ipbfree.com/index.php?s=&act=Stats&CODE=who&t="+tid, "WhoPosted", "toolbar=no,scrollbars=yes,resizable=yes,width=230,height=300");>Who Posted?</a>



but got 'page not found'

Please help?

This post has been edited by Inny: 18 Mar, 2008 - 05:07 PM
User is offlineProfile CardPM

Go to the top of the page


Inny
post 18 Mar, 2008 - 04:50 PM
Post #2


New D.I.C Head

*
Joined: 18 Mar, 2008
Posts: 13



Thanked 4 times
My Contributions


Anyone? I tried several Variations, but cant work out if i need 2 functions in the href, one to open the box one to find and add tid.

i thought it might be the quotes, i tried

CODE
<a href="java script:window.open('http://inny.ipbfree.com/index.php?s=&act=Stats&CODE=who&t='+tid, 'WhoPosted', 'toolbar=no,scrollbars=yes,resizable=yes,width=230,height=300')";>Who Posted?</a>


No joy sad.gif

then i tried 2 functions

CODE
<a href="java script:who_posted(tid);window.open('http://inny.ipbfree.com/index.php?s=&act=Stats&CODE=who&t='+tid, 'WhoPosted', 'toolbar=no,scrollbars=yes,resizable=yes,width=230,height=300')";>Who Posted?</a>


What am I doing wrong?

This post has been edited by Inny: 18 Mar, 2008 - 05:13 PM
User is offlineProfile CardPM

Go to the top of the page

Inny
post 21 Mar, 2008 - 09:14 PM
Post #3


New D.I.C Head

*
Joined: 18 Mar, 2008
Posts: 13



Thanked 4 times
My Contributions


Bump, c'mon does nobody bother helping js noobs?
User is offlineProfile CardPM

Go to the top of the page

supersloth
post 25 Mar, 2008 - 11:35 AM
Post #4


Pwnership is nine tenths of the LOL

Group Icon
Joined: 21 Mar, 2001
Posts: 18,773



Thanked 9 times

Dream Kudos: 2147483647

Expert In: being gentlemanly

My Contributions


they way you are doing it seems like a big pain in the ass, i would do it in a couple of lines rather than one, it makes it easier to read and to debug as well.


real quick based on what you got...
CODE


<script>
    function whatever(tid){
        var url = 'index.php?s=&act=Stats&CODE=who&t=' + tid;
        openwindow(url);
    }

    function openwindow(myUrl){
        window.open(myUrl, 'WhoPosted', 'toolbar=no,scrollbars=yes,resizable=yes,width=230,height=300')";>
    }

</script>
User is offlineProfile CardPM

Go to the top of the page

Inny
post 2 Apr, 2008 - 09:37 PM
Post #5


New D.I.C Head

*
Joined: 18 Mar, 2008
Posts: 13



Thanked 4 times
My Contributions


How would I call It?

<a href="java script:openwindow(myUrl)">who posted</a>

??? Not working
User is offlineProfile CardPM

Go to the top of the page

PsychoCoder
post 2 Apr, 2008 - 11:15 PM
Post #6


DIC.Rules == true;

Group Icon
Joined: 26 Jul, 2007
Posts: 7,225



Thanked 52 times

Dream Kudos: 7775

Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, GDI

My Contributions


Don't call the openwindow function, call the other function he listed.


HTML
<a href="java script:void(0);" onclick="whatever('428');">who posted</a>
User is online!Profile CardPM

Go to the top of the page

Inny
post 16 Jun, 2008 - 08:26 PM
Post #7


New D.I.C Head

*
Joined: 18 Mar, 2008
Posts: 13



Thanked 4 times
My Contributions


Thats working Great but requires a static href, I was hoping I could use a dynamic approach, perhaps regular expression to call the tid, whatever it may be. tids are dynamic.

eg something like?

<a href="java script:void(0);" onclick="whatever('$1');">who posted</a>
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 9/5/08 05:04PM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month