Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
adding to a variable (very simple)
Old 02-23-2006, 01:50 PM adding to a variable (very simple)
Average Talker

Posts: 29
Trades: 0
Hey, really simple question:

for the below code:

function sendText1(text)
{
e = document.form1.one
e.value = text

}

How can i make it so it adds the "text" variable to the textbox, and doesn't replace whats already in the text box.

Thanks alot
__________________
-ValC

Last edited by ValC; 02-23-2006 at 02:03 PM..
ValC is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 02-23-2006, 03:30 PM Re: adding to a variable (very simple)
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,519
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
e.value = e.value + text
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 03-08-2006, 06:20 AM Re: adding to a variable (very simple)
Average Talker

Posts: 29
Trades: 0
Thanks alot, i told u it was simple!

Now i have another lil problem.

How would i make it soin the code below it assigns e.value to a string then replaces all "IIIII" in that string with "V" then puts the string back into e.value

e = document.form1.one

if (text != ""){
e.value = e.value + text;

I tried
String I = e.value;
String I = findReplace(I, "IIIII", "V");
e.value = String I;

but it doesn't work

Thanks alot.
__________________
-ValC
ValC is offline
Reply With Quote
View Public Profile
 
Old 03-08-2006, 08:52 AM Re: adding to a variable (very simple)
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,519
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
e.value = e.replace( "IIIII", "V");
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 03-09-2006, 11:23 AM Re: adding to a variable (very simple)
Average Talker

Posts: 29
Trades: 0
doesn't work any ideas why?
__________________
-ValC
ValC is offline
Reply With Quote
View Public Profile
 
Old 03-09-2006, 04:26 PM Re: adding to a variable (very simple)
funkdaddu's Avatar
Web Design Snob

Posts: 635
Trades: 0
I think it should be:

e.value = e.value.replace("IIIII", "V");

Here's a working example:
HTML Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

	<head>
		<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
		<title>Untitled Page</title>
		<script type="text/javascript"><!--
function sendText(text) {
	e = document.form1.one
	
	if (text != ""){
		e.value = e.value.replace("IIIII", "V");
	}
}
//-->
</script>
	</head>

	<body bgcolor="#ffffff">
		<form id="form1" method="get" name="form1" onsubmit="sendText('test');return false;">
			<input type="text" name="one" value="IIIII" size="24"><input type="submit" name="submitButtonName">
		</form>
	</body>

</html>

Last edited by funkdaddu; 03-09-2006 at 04:31 PM..
funkdaddu is offline
Reply With Quote
View Public Profile Visit funkdaddu's homepage!
 
Old 03-10-2006, 02:06 PM Re: adding to a variable (very simple)
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,519
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
oops! it certainly should be e.value.replace
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to adding to a variable (very simple)
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

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





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.18617 seconds with 12 queries