Notices

Water Fountain General Chit/Chat

Reply
 
LinkBack Thread Tools
Old 04-23-04, 08:53 PM   #1 (permalink)
Aximsite Minor League
 
hanna975's Avatar
Member
 
Join Date: Mar 2003
Location: York, Pa
Posts: 166
Thanked 0 Times in 0 Posts
javascript question

Since there are alot of people who know their stuff here, got a javascript question.

I'm a complete newb to javascript and have an assignment for class(Intro to web design) I can't fiqure out for the life of me.

I need to create 2 text boxes and 2 buttoms that perform certain tasks in javascript.

The alert button I fiqured out(Display input from textbox1 in an alert window).

The switch button, I'm stuck on. I need to take the input from textbox1 and place in textbox2 when clicked. I declared the variable "switch" to use for that function. Here is the code I have so far. The question marks are where I'm stuck.

Thanks in advance on this one.

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>

<title>lab4/19</title>

<script type="text/javascript" language="javascript">

var switch;
switch = (stuff1)
function helloalert(input)
{
window.alert(input)
}
</script>

</head>

<body>

<h1>Lab 4/19</h1>

<p>Type anything in the first field</p>

<form>
<input name="stuff1" type="text" />
<input name="stuff2" type="text" /><br/>
<input name="alert" type="button" value="Alert"
onclick="helloalert(form.stuff1.value)" />
<input name="switch" type="button" value"Switch"
onclick=?????? />
</form>



</body>

</html>

Last edited by hanna975; 04-25-04 at 11:59 AM.
hanna975 is offline   Reply With Quote
Sponsor Ads
Old 04-25-04, 05:20 AM   #2 (permalink)
Aximsite Minor League
 
fremen's Avatar
Senior Member
 
Join Date: Oct 2003
Location: Australia
Posts: 252
Thanked 0 Times in 0 Posts
Does that all actually work for you? I copied that and tested it and it didn't work for me.

Anyhow I would suggest for textbox value transfers, using something like

document.<form name>.<Textbox2 name>.value = document.<form name>.<Textbox1 name>.value

so in your case, if you give your form the name of "Test"

Code:
document.Test.stuff2.value=document.Test.stuff1.value;
__________________
I wanted an Axim.
"The only way to live a good life is to act on your emotions"
I got an Axim.
fremen is offline   Reply With Quote
Old 04-25-04, 12:05 PM   #3 (permalink)
Aximsite Minor League
 
hanna975's Avatar
Member
 
Join Date: Mar 2003
Location: York, Pa
Posts: 166
Thanked 0 Times in 0 Posts
I did find something similar in another forum that helped me thru.
I ended up creating a switch funtion that did the trick.

Here's the whole code for both the switch and alert if you want it.

<head>

<title>lab4/19</title>

<script type="text/javascript" language="javascript">

function switch1(stuff1, stuff2)
{
var switch2 = stuff1.value
stuff1.value=stuff2.value
stuff2.value=switch2
}

function helloalert(input)
{
window.alert(input)
}

</script>

</head>

<body>

<h1>4/19</h1>

<p>Type anything in the first field</p>

<form>
<input type = "text" id="stuff1" />
<input type= "text" id="stuff2" /><br />
<input name="alert" type="button" value="Alert"
onclick="helloalert(form.stuff1.value)" />
<input type="button" value="Switch"
onclick="switch1(document.getElementById('stuff1') ,
document.getElementById('stuff2'))" />

</form>



</body>
hanna975 is offline   Reply With Quote
Reply

Sponsor Ads

Thread Tools

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 On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 10:04 PM.
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Copyright © 2003-09 LeckMedia, LLC