...

View Full Version : Need assistance in Selection Box



anaid54
09-11-2010, 04:56 PM
i have a selection menu here. what i would like to do is that when i select "not copy" it will not show and not copy the contents of "todo" textfield. but when i select any of the "copy text" it will show and copy the contents of the "todo" text. help plsssssssssssssssssss


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>

</head>

<body>
<form id="form" name="form" method="post" action="">
<p>Phone Number:
<input type="text" name="Name" />
</p>
<p>Location:
<select name="selector" >
<option>copy text</option>
<option>not copy text</option>
<option>copy text</option>
<option>copy text</option>
</select>
</p>
<p>To Do Today:
<input type="text" name="todo" />
</p>
<p>
<input type="button" value="Copy" />
</p>
</form>
</body>
</html>

Philip M
09-11-2010, 05:43 PM
Copy to where? The clipboard? A <div> on the same page? A pop-up? Another page?

What is the point of having several identical options <option>copy text</option>?

To capture the value of a selected option:-

optionValue = document.form.selector.value

But you have not assigned any values to the options. And it is a bad idea to name your form "form".


It is not as cold as it was yesterday, but that's probably because it's a bit warmer. - BBC Scotland News.

anaid54
09-11-2010, 06:43 PM
this is just an example of what i am working on. it will copy to the text area in another frame. parent.mainFrame.textArea.value

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>

</head>

<body>
<form id="form" name="form1" method="post" action="">
<p>Phone Number:
<input type="text" id="Name" name="Name" />
</p>
<p>Location:
<select name="selector" id="selector" >
<option>copy text</option>
<option>not copy text</option>
<option>copy text</option>
<option>copy text</option>
</select>
</p>
<p>To Do Today:
<input type="text" id="todo"name="todo" />
</p>
<p>
<input type="button" id="mybutton" value="Copy" />
</p>
</form>
</body>
</html>

Philip M
09-11-2010, 07:50 PM
<input type="text" id="Name" name="Name" />
Although Name and name are not the same (Javscript is case sensitive) it is still a bad idea.
And why is a field supposed to be a phone number given the name "Name"?

I still do not understand why several options are the same.
You need to assign values to your options:-


<select name="selector" id="selector" >
<option value = 1>copy text</option>
<option value = 2>not copy text</option>
<option value = 3>copy text</option>
<option value = 4>copy text</option>
</select>
Then in script:-

var op = document.form1.selector.value;
if ((op == 1) || (op == 3) || (op == 4)) {
parent.mainFrame.textArea.value = document.form1.todo.value;
}


BTW, when posting here please follow the posting guidelines and wrap your code in CODE tags. This means use the octothorpe or # button on the toolbar. You can (and should) edit your previous post.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum