|
-
December 7th, 2004, 10:34 PM
#1
Moving Information from list box to textarea
Hi guys,
I have a problem with my javascript. I need to move values in the list box to a textarea in the same page but in different forms. When i select the value in the list box and click on the button it should print something like this:
start telnet 192.168.111.80
start /w LAN789.vbs
cls
start telnet 192.168.111.81
start /w LAN789.vbs
cls
The IP address is a value from the list box. I am also wondering if it is possible to select multiple and print it all out in the textarea like the above. The list box get its values from the database.
Thanks
Irwin
-
December 8th, 2004, 12:55 AM
#2
Re: Moving Information from list box to textarea
What have you got so far ?
To get help with your code, you have to show us your code.
The biggest problem encountered while trying to design a system that was completely foolproof,
was, that people tended to underestimate the ingenuity of complete fools.
Douglas Adams
-
December 8th, 2004, 08:52 PM
#3
Re: Moving Information from list box to textarea
This is my javascript:
<SCRIPT LANGUAGE="JavaScript"><!--
function additive() {
document.form1.BATfile.value += document.form1.select1.options[document.form1.select1.selectedIndex].text + "\n";
}
//--></SCRIPT>
This is my list box:
<form name="form1" method="post" action="">
<select name="select1" size="10">
<%
While (NOT objRS.EOF)
%>
<option value="<%=(objRS.Fields.Item("GRP").Value)%>" <%If (Not isNull((objRS.Fields.Item("GRP").Value))) Then If (CStr(objRS.Fields.Item("GRP").Value) = CStr((objRS.Fields.Item("GRP").Value))) Then Response.Write("SELECTED") : Response.Write("")%> ><%=(objRS.Fields.Item("GRP").Value)%></option>
<%
objRS.MoveNext()
Wend
If (objRS.CursorType > 0) Then
objRS.MoveFirst
Else
objRS.Requery
End If
%>
</select>
<br>
<input type="submit" name="Submit" value="Add" onClick="additive()">
<br>
</form>
This is the textarea:
<form action="<%=request.ServerVariables("SCRIPT_NAME")%>" method="post" name="formBATfile" id="formBATfile">
<font color="#4799B6" face="Arial, Helvetica, sans-serif">Enter BAT Commands:</font><br>
<textarea name="BATfile" cols="55" rows="18" wrap="VIRTUAL"><%=textFile1%></textarea>
<br>
<input name="saveBat" type="submit" id="saveBat" value="Save">
<input type="hidden" name="VB" value="<%=request("VB")%>">
<input type="hidden" name="BAT" value="<%=request("BAT")%>">
<input type="hidden" name="callback1" value="true">
</form>
Thanks
Irwin
-
December 9th, 2004, 12:31 AM
#4
Re: Moving Information from list box to textarea
This line
Code:
document.form1.BATfile.value += document.form1.select1.options[document.form1.select1.selectedIndex].text + "\n";
Should be
Code:
document.formBATfile.BATfile.value += document.form1.select1.options[document.form1.select1.selectedIndex].text + "\n";
And you might want to change the type attribute on the form1 add button from 'submit' to 'button' this avoids having the page reload to it's original state every time you press add.
Last edited by khp; December 9th, 2004 at 12:35 AM.
The biggest problem encountered while trying to design a system that was completely foolproof,
was, that people tended to underestimate the ingenuity of complete fools.
Douglas Adams
-
December 9th, 2004, 04:17 AM
#5
Re: Moving Information from list box to textarea
Thanks for the help. I can now add the value in.
But there is still the other values like
start telnet 192.168.111.81
start /w LAN789.vbs
cls
The other values are fixed, is it possible to add them in.
If I want it to be able to add multiple values(shown above) how it is done.
Thanks
Irwin
-
December 9th, 2004, 04:38 AM
#6
Re: Moving Information from list box to textarea
This page shows an example of working with a multiselect in javascript.
http://www.mredkj.com/tutorials/tutorial004.html
The biggest problem encountered while trying to design a system that was completely foolproof,
was, that people tended to underestimate the ingenuity of complete fools.
Douglas Adams
-
December 9th, 2004, 11:10 PM
#7
Re: Moving Information from list box to textarea
Thanks alot. But I have values in the textarea and the values i send to the textarea is at the bottom of the textarea. How do I move it to the top.
Irwin
-
December 9th, 2004, 11:22 PM
#8
Re: Moving Information from list box to textarea
 Originally Posted by lchi
Thanks alot. But I have values in the textarea and the values i send to the textarea is at the bottom of the textarea. How do I move it to the top.
I would think something like
Code:
document.formBATfile.BATfile.value = document.form1.select1.options[document.form1.select1.selectedIndex].text + "\n" + document.formBATfile.BATfile.value;
Should do.
Last edited by khp; December 9th, 2004 at 11:26 PM.
The biggest problem encountered while trying to design a system that was completely foolproof,
was, that people tended to underestimate the ingenuity of complete fools.
Douglas Adams
-
December 12th, 2004, 10:03 PM
#9
Re: Moving Information from list box to textarea
Thanks. But how you add the other values like
start telnet xxx.xxx.xxx.xxx
start /w LAN789.vbs
cls
Please help me on this.
-
December 12th, 2004, 11:16 PM
#10
Re: Moving Information from list box to textarea
 Originally Posted by lchi
Thanks. But how you add the other values like...
Ehh, add more options to the select.
Perhaps I'am not quite understanding you.
The biggest problem encountered while trying to design a system that was completely foolproof,
was, that people tended to underestimate the ingenuity of complete fools.
Douglas Adams
-
December 13th, 2004, 01:17 AM
#11
Re: Moving Information from list box to textarea
What I mean is when I add the IP address in, the other values will be added in the textarea as shown like this:
start telnet xxx.xxx.xxx.xxx
start /w LAN789.vbs
cls
The xxx.xxx.xxx.xxx being the value from the list box and the other values are fixed.
Sorry if I was not clear.
Thanks
Irwin
-
December 13th, 2004, 01:33 AM
#12
Re: Moving Information from list box to textarea
Don't you have any understanding of what a line like
Code:
document.formBATfile.BATfile.value = document.form1.select1.options[document.form1.select1.selectedIndex].text + "\n" + document.formBATfile.BATfile.value;
Does ?
It concatenates strings and assings the result to the text area.
To add more fixed values to the text area just add more string literals to the above line. Something like
Code:
document.formBATfile.BATfile.value = "start telnet " + document.form1.select1.options[document.form1.select1.selectedIndex].text + "\nstart /w LAN789.vbs\ncls\n" + document.formBATfile.BATfile.value;
The biggest problem encountered while trying to design a system that was completely foolproof,
was, that people tended to underestimate the ingenuity of complete fools.
Douglas Adams
-
December 13th, 2004, 01:52 AM
#13
Re: Moving Information from list box to textarea
I do not understand that line. I am very new at this and I only know very simple things. I am trying to understand the codes but it prove very difficult.
Irwin
-
December 13th, 2004, 04:42 AM
#14
Re: Moving Information from list box to textarea
Well I'll this is what this line does:
Code:
document.formBATfile.BATfile.value = document.form1.select1.options[document.form1.select1.selectedIndex].text + "\n" + document.formBATfile.BATfile.value;
Replace the content of the element named BATfile in the form named formBATfile with the content of the currently selected item in the list box named options appended to what is already in the element BATFile.
Hence, if the element BATfile contains the text:
"is my name"
and the value of the text of the currently selected list item is "Adam" then the above line of code will change the text of the element BATfile to:
"Adam
is my name"
I am afraid I cannot make it any clearer.
-
December 13th, 2004, 10:51 AM
#15
Re: Moving Information from list box to textarea
 Originally Posted by lchi
I do not understand that line. I am very new at this and I only know very simple things. I am trying to understand the codes but it prove very difficult.
Irwin
You need to go read some more tutorials, and don't just copy their code, try to understand what they are doing.
http://www.w3schools.com/js/default.asp
You cannot develop a javascript by asking for help everytime you need to change the tiniest bit.
The biggest problem encountered while trying to design a system that was completely foolproof,
was, that people tended to underestimate the ingenuity of complete fools.
Douglas Adams
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|