6 Replies - 9021 Views - Last Post: 16 June 2008 - 08:26 PM

#1 Inny   User is offline

  • New D.I.C Head

Reputation: 4
  • View blog
  • Posts: 20
  • Joined: 18-March 08

parse query string in href function?

Posted 18 March 2008 - 03:49 AM

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

<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

<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....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}

<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
<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 March 2008 - 05:07 PM


Is This A Good Question/Topic? 1

Replies To: parse query string in href function?

#2 Inny   User is offline

  • New D.I.C Head

Reputation: 4
  • View blog
  • Posts: 20
  • Joined: 18-March 08

Re: parse query string in href function?

Posted 18 March 2008 - 04:50 PM

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

<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 :(

then i tried 2 functions

<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 March 2008 - 05:13 PM

Was This Post Helpful? 1

#3 Inny   User is offline

  • New D.I.C Head

Reputation: 4
  • View blog
  • Posts: 20
  • Joined: 18-March 08

Re: parse query string in href function?

Posted 21 March 2008 - 09:14 PM

Bump, c'mon does nobody bother helping js noobs?
Was This Post Helpful? 1

#4 supersloth   User is offline

  • serial frotteur - RUDEST MEMBER ON D.I.C.
  • member icon


Reputation: 4678
  • View blog
  • Posts: 28,500
  • Joined: 21-March 01

Re: parse query string in href function?

Posted 25 March 2008 - 11:35 AM

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

<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>


Was This Post Helpful? 1

#5 Inny   User is offline

  • New D.I.C Head

Reputation: 4
  • View blog
  • Posts: 20
  • Joined: 18-March 08

Re: parse query string in href function?

Posted 02 April 2008 - 09:37 PM

How would I call It?

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

??? Not working
Was This Post Helpful? 1

#6 PsychoCoder   User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1663
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: parse query string in href function?

Posted 02 April 2008 - 11:15 PM

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


<a href="java script:void(0);" onclick="whatever('428');">who posted</a>

Was This Post Helpful? 0
  • +
  • -

#7 Inny   User is offline

  • New D.I.C Head

Reputation: 4
  • View blog
  • Posts: 20
  • Joined: 18-March 08

Re: parse query string in href function?

Posted 16 June 2008 - 08:26 PM

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>
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1