/    Sign up×
Community /Pin to ProfileBookmark

Copying text from one area to another

If I have data sorted by different dates is there a way where I find the range between two certain dates and then take that certain text and dispay it somewhere else, either in another link or in hideable DIV that will open when I have the text? I figured out the way to compare the different dates but I’m stuck as far as how to obtain the specific part of the textand pasting it somewhere else. Thanks for any help!

to post a comment
JavaScript

9 Comments(s)

Copy linkTweet thisAlerts:
@A1ien51Jul 01.2005 — basic ideas:

other text area

document.FormName.elementName2.value = document.FormName.elementName1.value;

a div

document.getElementById("divID").innerHTML = document.FormName.elementName1.value;

Eric
Copy linkTweet thisAlerts:
@redakasashaauthorJul 01.2005 — what would elementName1 be?
Copy linkTweet thisAlerts:
@A1ien51Jul 01.2005 — the name of a text box.

You really did not give clues on how you have the dates, so I used a textbox.

Eric
Copy linkTweet thisAlerts:
@crh3675Jul 01.2005 — <i>
</i>&lt;html&gt;
&lt;script type="text/javascript"&gt;

function getFilter(rangestart,rangeend){

<i> </i> var rstart=new Date(rangestart).valueOf();
<i> </i> var rend=new Date(rangeend).valueOf();
<i> </i> var coll=document.getElementsByTagName("TD");
<i> </i> var hidtable=document.createElement("TABLE");
<i> </i> hidtable.id="hidResults";

<i> </i> for(i=0;i&lt;coll.length;i++){
<i> </i> if(coll[i].id.match(/^row(d+)date$/)){
<i> </i> rdate=new Date(coll[i].innerHTML).valueOf();
<i> </i> if(rdate&gt;=rstart &amp;&amp; rdate&lt;=rend){
<i> </i> mytr=coll[i].parentNode.cloneNode(true);
<i> </i> hidtable.appendChild(mytr);
<i> </i> }
<i> </i>}
<i> </i> }

<i> </i> document.body.appendChild(hidtable);

}
&lt;/script&gt;


&lt;body&gt;

&lt;table border="1"&gt;
&lt;tr&gt;
&lt;td id="row1id"&gt;1&lt;/td&gt;&lt;td id="row1date"&gt;05/01/2005&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td id="row2id"&gt;2&lt;/td&gt;&lt;td id="row2date"&gt;05/05/2005&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td id="row3id"&gt;3&lt;/td&gt;&lt;td id="row3date"&gt;04/05/2005&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td id="row4id"&gt;4&lt;/td&gt;&lt;td id="row4date"&gt;04/01/2004&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td id="row5id"&gt;5&lt;/td&gt;&lt;td id="row5date"&gt;04/05/2005&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td id="row6id"&gt;6&lt;/td&gt;&lt;td id="row6date"&gt;03/02/2005&lt;/td&gt;
&lt;/tr&gt;&lt;tr&gt;
&lt;td id="row7id"&gt;7&lt;/td&gt;&lt;td id="row7date"&gt;10/05/2004&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;

&lt;form&gt;
&lt;input type="button" onclick="getFilter('05/01/2005','05/15/2005')" value="click"&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;

Copy linkTweet thisAlerts:
@redakasashaauthorJul 01.2005 — I have all my text in a DIV and it is seperated by dates like this:

<div class="para" id="sub1" style="display:none">

06/10/2005

blah blah blah blah blah blah blah blah

06/25/2005

blah1 blah1 blah1 blah1 blah1 blah1 blah1 blah1

06/26/2005

blah2 blah2 blah2 blah2 blah2 blah2 blah2 blah2

07/01/2005

blah3 blah3 blah3 blah3

</div>

So if a user specifies that he wants info from 06/25/2005 to 06/26/2005 then I would take that portion of my text and paste it in another div like this:

<div class="para" id="sub4" style="display:none">

06/25/2005

blah1 blah1 blah1 blah1 blah1 blah1 blah1 blah1

06/26/2005

blah2 blah2 blah2 blah2 blah2 blah2 blah2 blah2

</div>

How would you do it in this case?

Thanks for the help Eric
Copy linkTweet thisAlerts:
@redakasashaauthorJul 01.2005 — Hey Craig I don't know if I am messing up somewhere or not but that code isn't working properly I think. It's just printing out the table with the dates but when I click on the button nothing happens.
Copy linkTweet thisAlerts:
@crh3675Jul 01.2005 — IE does something funny with it for some reason and doesn't show the table.


Try this one (uses a popup)
<i>
</i>&lt;html&gt;
&lt;script type="text/javascript"&gt;

function getFilter(rangestart,rangeend){

<i> </i> var rstart=new Date(rangestart).valueOf();
<i> </i> var rend=new Date(rangeend).valueOf();
<i> </i> var coll=document.getElementsByTagName("TD");
<i> </i> var hidtable=document.createElement("TABLE");
<i> </i> hidtable.id="hidResults";

<i> </i> for(i=0;i&lt;coll.length;i++){
<i> </i> if(coll[i].id.match(/^row(d+)date$/)){
<i> </i> rdate=new Date(coll[i].innerHTML).valueOf();
<i> </i> if(rdate&gt;=rstart &amp;&amp; rdate&lt;=rend){
<i> </i> mytr=coll[i].parentNode.cloneNode(true);
<i> </i> hidtable.appendChild(mytr);
<i> </i> }
<i> </i>}
<i> </i> }

<i> </i> document.getElementById("newResults").appendChild(hidtable)

<i> </i> var pwin=window.open('','','width=400,height=500,scrollbars=yes,toolbar=no,location=no,resizable=yes');
<i> </i> pwin.document.open();
<i> </i> pwin.document.write(document.getElementById("newResults").innerHTML);
<i> </i> pwin.document.close();

}
&lt;/script&gt;


&lt;body&gt;

&lt;table border="1"&gt;
&lt;tr&gt;
&lt;td id="row1id"&gt;1&lt;/td&gt;&lt;td id="row1date"&gt;05/01/2005&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td id="row2id"&gt;2&lt;/td&gt;&lt;td id="row2date"&gt;05/05/2005&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td id="row3id"&gt;3&lt;/td&gt;&lt;td id="row3date"&gt;04/05/2005&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td id="row4id"&gt;4&lt;/td&gt;&lt;td id="row4date"&gt;04/01/2004&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td id="row5id"&gt;5&lt;/td&gt;&lt;td id="row5date"&gt;04/05/2005&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td id="row6id"&gt;6&lt;/td&gt;&lt;td id="row6date"&gt;03/02/2005&lt;/td&gt;
&lt;/tr&gt;&lt;tr&gt;
&lt;td id="row7id"&gt;7&lt;/td&gt;&lt;td id="row7date"&gt;10/05/2004&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;div id="newResults" style="display:none"&gt;
&lt;/div&gt;

&lt;form&gt;
&lt;input type="button" onclick="getFilter('05/01/2005','05/15/2005')" value="click"&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;

Copy linkTweet thisAlerts:
@redakasashaauthorJul 01.2005 — That works...thanks Craig!
Copy linkTweet thisAlerts:
@google_archive1Jul 27.2005 — indexed JUL 27 2005 11:56:28
×

Success!

Help @redakasasha spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.6,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...