Important alert: (current site time 7/15/2013 1:04:45 PM EDT)
 

VB icon

CommandLine input handling

Email
Submitted on: 8/12/1999
By: Iwan Westerduin  
Level: Not Given
User Rating: By 1 Users
Compatibility: JavaScript
Views: 9559
 
     This code looks for given command line variables and passes them to a form. Great for passing data between webpages or from a plug-in such as Macromedia Shockwave Flash
 
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
'**************************************
' for :CommandLine input handling
'**************************************
<form name="Form1">
 <input type="text" name="T1" size="20">
 <input type="text" name="T2" size="20">
</form>
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
				
'**************************************
' Name: CommandLine input handling
' Description:This code looks for given command line variables and passes them to a form.
Great for passing data between webpages or from a plug-in such as Macromedia Shockwave Flash
' By: Iwan Westerduin
'
' Inputs:[url of page].htm?name=[firstname]%20[lastname]&email=[e-mail address]
'
' Returns:the code returns the given firstname, lastname and e-mail address in a form
'
' Assumes:Place the code in a html file and save it,
to use it, just pass the following url from another webpage (from a hyperlink or so) or plug-in:
[url of page].htm?name=[firstname]%20[lastname]&email=[e-mail address]
'
' Side Effects:none... as far as i know
'
'This code is copyrighted and has' limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=1667&lngWId=14'for details.'**************************************

var username, user;
var userstring = location.href;
var nameStart = userstring.indexOf('name=')+5;
var nameEnd = userstring.indexOf('&');
var emailStart = userstring.indexOf('email=')+6;
var findquery = (userstring.indexOf('?') == -1);
function replace(myString,from,to){
	index = myString.indexOf(from);
	if(!myString || index == -1){
		return myString;
	}
	else {
		return(myString.substring(0,index) + to + replace(myString.substring(index + from.length),from, to));
	}
}
if (!findquery){
	username = replace(userstring.substring(nameStart, nameEnd),'%20', ' ');
	user = userstring.substring(emailStart, (userstring.length));
}
else {
	username = '';
	user = '';
}
Form1.T1.value=username
Form1.T2.value=user


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Not Given category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments

1/23/2004 7:26:30 AM

coco
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.