Contact Us Forum Rules Search Archive
WebProWorld Part of WebProNews.com
Page One Link To Us Edit Profile Private Messages Archives FAQ RSS Feeds  
 

Go Back   WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Subscribe to the Newsletter FREE!


Register FAQ Members List Calendar Arcade Chatbox Mark Forums Read

Web Programming Discussion Forum Working with an API? Developing a plugin? Writing a Mod or script for your favorite blog, Web 2.0 site or Forum? Welcome.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-01-2008, 10:23 AM
WebProWorld New Member
 

Join Date: Oct 2008
Location: Danville Va
Posts: 9
dozzn RepRank 0
Default Need help with javascript variable

Hey everyone, this is my first posting!

I have been working on this script for a while but I still haven't figured it out.. I was hoping someone may be able to help.

The following script displays an eBay User's current items:



<script language="JavaScript" type="text/javascript">
<!--//
var myID="solditagain";document.write("<scri"+"pt language='"+"JavaScript' "+"sr"+"c=\"
Reply With Quote
  #2 (permalink)  
Old 10-01-2008, 10:28 AM
WebProWorld New Member
 

Join Date: Oct 2008
Location: Danville Va
Posts: 9
dozzn RepRank 0
Default Re: Need help with javascript variable

hmm What happened to the rest of the message?
Reply With Quote
  #3 (permalink)  
Old 10-01-2008, 11:18 AM
Dubbya's Avatar
WebProWorld 1,000+ Club
 

Join Date: Nov 2006
Location: Steinbach, Manitoba, Canada
Posts: 1,396
Dubbya RepRank 3Dubbya RepRank 3Dubbya RepRank 3
Default Re: Need help with javascript variable

It's a security measure employed to keep hackers from executing malicious scripts. You'll want to use the code delimiters to prevent the script from getting stripped out of your post when you submit it.

Type out your message as usual. When you're ready to paste in your code, just use the opening code delimiter (square bracket, the word "code" and a closing bracket). Paste in your javascript and close the code delimiter with another square bracket, a forward slash and a closing bracket.

It should look something like this:

HTML Code:
[code] 	
<script language="JavaScript" type="text/javascript">
<!--//
your var = some javascript code goes here.
//-->
</script>[/code]
With the script safely inside the code delimiters, it won't be stripped out of your message.

Go ahead and try posting it again.

.02
__________________
Printer ink, inkjet & toner cartridges in Canada
"Price-wise printing supplies"
inkjetOasis.ca
Reply With Quote
  #4 (permalink)  
Old 10-01-2008, 11:50 AM
WebProWorld New Member
 

Join Date: Oct 2008
Location: Danville Va
Posts: 9
dozzn RepRank 0
Default Re: Need help with javascript variable

Hey thanks for the reply!
Let me try this out again...

Ok, my script displays an eBay user's current items.



HTML Code:
[code]

<script language="JavaScript" type="text/javascript">
<!--//
var myID="solditagain";document.write("<scri"+"pt language='"+"JavaScript' "+"sr"+"c=\"http://lapi.ebay.com/ws/eBayISAPI.dll?EKServer&paypal=y&popup=y&hdrcolor=ffffff&fs=1&endcolor=ee4444&num=30&cid=0&sortdir=asc&tlecolor=ffcc00&sortby=endtime&track=&srchdesc=n&width=600&siteid=0&bdrcolor=ffffff&logo=1&numbid=y&ai=tedsaodd&prvd=0&fntcolor=000000&sort=MetaEndSort&si="+myID+"&endtime=y&title=Current+listings+for+"+myID+"&img=y\" ebay=\"http:\/\/include.ebaystatic.com\/\"></scr"+"ipt>");
//--></script>  

[/code]


I want to make it so that users can click on another user's name (a link) and view their current items.

Example:

myname
yourname
bobsname




How to pass the id variable using a link?

I don't want to make out a seperate page for each user, this needs to be 2 pages at the most.
Also, my web host doesn't support PHP...

Is there any other way this can be achieved?

Thanks for your time,
Daniel
Reply With Quote
  #5 (permalink)  
Old 10-02-2008, 02:16 PM
Dubbya's Avatar
WebProWorld 1,000+ Club
 

Join Date: Nov 2006
Location: Steinbach, Manitoba, Canada
Posts: 1,396
Dubbya RepRank 3Dubbya RepRank 3Dubbya RepRank 3
Default Re: Need help with javascript variable

How you get the user's ID number will be up to you to figure out, as will figuring out how to dynamically write the hyperlinks in your html page.

Put the items script inside a function, then use a javascript onclick event handler to call the function and pass the user's ID number (solditagain) as a variable in the hyperlink.

confused?

Here's one way to do it using the document.write method:
Code:
<script language="JavaScript" type="text/javascript">
<!--//
function viewItems(solditagain){

var myID="solditagain";document.write("<scri"+"pt language='"+"JavaScript' "+"sr"+"c=\"http://lapi.ebay.com/ws/eBayISAPI.dll?EKServer&paypal=y&popup=y&hdrcolor=ffffff&fs=1&endcolor=ee4444&num=30&cid=0&sortdir=asc&tlecolor=ffcc00&sortby=endtime&track=&srchdesc=n&width=600&siteid=0&bdrcolor=ffffff&logo=1&numbid=y&ai=tedsaodd&prvd=0&fntcolor=000000&sort=MetaEndSort&si="+myID+"&endtime=y&title=Current+listings+for+"+myID+"&img=y\" ebay=\"http:\/\/include.ebaystatic.com\/\"></scr"+"ipt>"); 
}
//-->
</script>
Here's the hyperlink you'd use:
HTML Code:
<a href="#" onclick="viewItems('you have to put the id number here');return false;">View Bob's Items</a>
This will work in Google Chrome, IE6/IE7, Netscape, Opera, Firefox and Safari.

There are those that would recommend using proper DOM (Document Object Model) methods to do this. In this case you get what you paid for. The rest is up to you.

Good Luck.
__________________
Printer ink, inkjet & toner cartridges in Canada
"Price-wise printing supplies"
inkjetOasis.ca
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Tags:



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
undefine variable jinchiruki Web Programming Discussion Forum 6 02-20-2008 02:44 AM
Can I get a variable name as a string? montyauto Web Programming Discussion Forum 12 01-18-2007 06:20 PM
Passing a variable through the url netman4ttm Web Programming Discussion Forum 2 06-15-2005 11:50 AM
PHP Variable NOT NULL richkoi Database Discussion Forum 5 06-07-2005 04:42 PM
Variable Stylesheets MrLeN Graphics & Design Discussion Forum 9 11-30-2003 02:39 PM


Search Engine Optimization by vBSEO 3.2.0