SeanFlynn
SeanFlynn

Reputation: 453

Javascript Submit With GetElementByID - Open in New Window

I have a page called "review.asp" with a form that produces a list of records from a database. If the user wants to see more information about a particular record, they just click on the "prjName" field, which is a hyperlink. Then, the page will submit and display information about the record. Currently, this opens in the same window. I'd like it to open to a new window.

Additionally, I don't want to just put a target = _blank in the form part of the HTML because this page does several submits and I don't want them ALL to open in a new window - just this one below. So, I'm hoping there is a solution for this within the Javascript?

Thanks in advance!

My HTML:

<form name="frmPrjReview" id="frmPrjReview" method="post">
<p><a href="javascript:selectRecID('<%= RS("recID")%>')";><%=RS("prjName")%></a></p>

My current Javascript:

function selectRecID(recID)
{
    //Set the value of the hidden text field = to the record ID in the table.
    document.getElementById("txtRecID").value = recID;

    var submitSearch = document.getElementById("frmPrjReview");

    submitSearch.action = "review.asp"; 
    submitSearch.submit();
}

Upvotes: 1

Views: 926

Answers (1)

Art
Art

Reputation: 5924

Set the target programatically when you need it:

var submitSearch = document.getElementById("frmPrjReview");
...
submitSearch.setAttribute("target", "_blank");
submitSearch.submit();
submitSearch.removeAttribute("target")

EDIT: to add removal.

Upvotes: 2

Related Questions