John W. Hinckley Jr. stalked out of his trial yesterday, deputy marshals trailing behind, after he heard actress Jodie Foster testify on videotape, "I don't have any relationship with John Hinckley."

His dramatic exit and clear distress were in sharp contrast to his calm demeanor when, just hours earlier, his father broke into tears on the witness stand and told the jury: "I am the cause of John's tragedy . . . I wish to God I could trade places with him right now."

Describing how he had forced his younger son out of the family home three weeks before the 26-year-old college dropout shot President Reagan, John W. Hinckley Sr. testified, "I'm sure that was the greatest mistake in my life."

While his father spoke, Hinckley's mother, JoAnn, was led from the courtroom in tears. Hinckley sat stiff and emotionless throughout.

"We forced him out at a time when he just couldn't cope," Hinckley's father said on the seventh day of testimony in his son's trial on charges of attempting to assassinate the president.

After the elder Hinckley's three hours of testimony, defense lawyers played previously videotaped testimony by Foster, whom Hinckley pursued with letters and telephone calls in the months before the attack on Reagan.

Hinckley, seated at the defense table in the well of the courtroom, appeared astonished when Foster said on the tape that she had never seen him before the hearing in which her testimony was recorded.

Clearly distressed, he looked toward the spectators in the courtroom, pushed out his chair, turned back and headed for the door to the cellblock behind the judge's bench.

The videotape of Foster continued to play without a pause as deputy marshals closed in around Hinckley and quietly walked out with him. No effort was made to stop the trial. Forty-five minutes later, when the tape was finished, Hinckley was brought back into the courtroom.

It was confirmed yesterday that Hinckley caused a similar dramatic interruption in the closed hearing in March in which Foster's testimony was videotaped for use at his trial. In that session, sources said, near the end of Foster's testimony Hinckley threw a pen in her direction. He was taken out of the courtroom and did not return. Foster's testimony was taped because she was scheduled to be out of the country at the time of the trial.

His surprising exit yesterday and his father's emotional testimony followed days of defense witnesses' accounts of Hinckley's growing depression and isolation in the months before he shot Reagan, and about his frustrated obsession with Foster.

The defense contends that Hinckley was legally insane when he fired on the president, but the prosecution argues it was a planned and deliberate act.

Yesterday defense lawyers introduced a batch of notes Hinckley wrote to Foster, including one dated March 6, 1981, 24 days before the attack on Reagan.

"Jodie, GOODBYE! I love you six trillion times. DON'T YOU MAYBE LIKE ME A LITTLE BIT? (YOU MUST ADMIT I AM DIFFERENT). It would make all of this worthwhile," that note said. The message, which Foster received at Yale University where she was a student, was signed "JOHN HINCKLEY of course."

In another note to Foster, received about the same time as the first and signed "JWH," Hinckley wrote in bold print: "Jodie Foster Love, Just Wait. I'll rescue you very soon. Please cooperate." Foster testified that Travis Bickel, the main character in the film "Taxi Driver," sent a similar rescue note to a young prostitute named Iris. Foster played that role in the film, which Hinckley saw at least 15 times.

Foster, who had been told of a kidnaping threat in November 1980, turned both notes and others signed by Hinckley over to her college dean. She testified on the tape that she had thrown out other notes and poems signed by Hinckley that she received in the fall. She described the notes she received in March as "more distressed than the others."

Hinckley was present in the courtroom for the beginning of Foster's testimony, when the notes were introduced and discussed. At times as she spoke he looked away from a television monitor and laid his head down in his hands.

On the day Reagan was shot, law enforcement officials confiscated an unmailed letter to Foster that they found in Hinckley's Washington hotel room. In it, he wrote: "Jody, I'm asking you to please look into your heart and at least give me the chance with this historic deed to gain your respect and love."

Five photographs of Foster, also introduced into evidence, were found in Hinckley's wallet when he was arrested, as well as her address and phone number at Yale.

On March 6, three hours after he left the note for Foster at Yale, Hinckley made a frantic telephone call to his parents from New York City, saying he was sick and penniless, pleading to come home.

Hinckley senior, saying he had been advised by a psychiatrist to "get control of the situation," testified he told his son: "John, that is tough. Try to find some money. Go to the Salvation Army or a church or a policeman or anybody you can think of that might have money to serve your needs."

An hour later, his son called back and said," 'I still don't have any money,' " Hinckley said. He arranged for his son to borrow some money from a business associate in New York. John Hinckley Jr. bought a hamburger, took a limousine to the airport and came home to Denver, his father told the jury.

Hinckley's parents had drawn up a plan, on the advice of a psychiatrist, that Hinckley have a job by March 1 and be out of the house by March 30--the day he shot Reagan. As he drove to the airport to meet his son March 7, Hinckley's father testified yesterday, his voice strained with emotion, "I prayed all the way that we were doing the right thing."

At the airport, Hinckley said, his son "was in very bad shape. He needed a shave. He was wiped out. He could hardly walk from the plane.

"We sat down and I told him how disappointed I was in him. How he had let us down, how he had not followed the plan we had all agreed on. He had left us no choice but to not take him back to the house again but to force him to go on his own. So that's what I did," Hinckey's father testified.

In a parking lot, Hinckley's father said, he gave his son a couple of hundred dollars he had brought from the family house.

"I suggested he go to the YMCA. He said he didn't want to do that. I said, 'Okay, you're on your own. Do whatever you want to do,' " his father said.

"In looking back on that I'm sure that was the greatest mistake in my life. I am the cause of John's tragedy," he said. Judge Barrington D. Parker called a recess in the proceedings, and the jury was taken from the courtroom as Hinckley's father began to cry openly, holding a white handkerchief tight over his eyes.

Hinckley said his son moved into a motel and was next heard from on about March 23, when he said he wanted to return to California, where he had tried before to pursue a career as a rock star.

"I was very upset to hear it again. I asked him why and he didn't seem to have a good reason," Hinckley's father said. When Hinckley said he wanted to sell his car and keep the money, his father testified "I refused to do that."

The next time Hinckley senior heard about his son was on March 30, after he learned of the shooting of the president--but not about a suspect--over lunch. Hinckley, chairman of the board of a Colorado-based oil and gas exploration company, said when he returned to his Denver office his chief accountant, his face pale, came in.

"Jack, I think there is something you need to hear," Hinckley said the accountant told him.

In years that Hinckley had dropped in and out of college in Lubbock, Tex., his father said, he had written home in detail about a girlfriend in California he identified as "Lynn Collins."

When his son wrote in 1976 about a trip that he and "Lynn" had taken to Malibu, his father said, "We were glad to hear he was enjoying himself . . . but I didn't want him to get carried away with it." He reminded his son that it was time to be self-sufficient and to make plans for a job "so that we wouldn't have to keep supporting him."

Hinckley's father said the family learned after the March 30 shooting that Lynn Collins did not exist.

"We were astounded," he said.

The elder Hinckley, wearing a dark, pinstriped business suit and leaning forward in the witness chair as he testified, said that 1977 was the last year that his son "was able to cope with his life." The younger Hinckley became caught up with physical complaints for which doctors could find no cause, spent some time in school, moved to Dallas where he had a small apartment and by 1979 "seemed more and more depressed," his father testified.

As his son's condition deteriorated, Hinckley said, there was talk about sending him to an institution, but a psychiatrist, Dr. John Hopper had opposed the idea.

Meanwhile, Hinckley said, he did not know that his son had criss-crossed the country in September and October of 1980 and he didn't know about Jodie Foster. He didn't know, he said, that his son had been arrested that October in Nashville, trying to get a suitcase full of guns through an airport magnetometer on the same day President Carter made a campaign appearance there.

"I only wish to God I had," Hinckley's father said.