Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Struts question: Problem changing the action and submitting the page using javacript

Status
Not open for further replies.

csphard

Programmer
Apr 5, 2002
194
US
I have a form that has an action. I am trying to redirect the page to another action using javascript after setting some cookies.
My question is will the struts-config.xml action always be in control even though you are trying to change action and submit it using javascript.

I get to here alert("first try made it here "); but I never get the following to happen. It just stope.

frm.action = "acms/int/intakeHistory.do?function=getInt";
frm.submit();

Is there something that I am missing.


JAVASCRIPT
if (cookie == null){
deleteCookie("JSUBJECTID");
setCookie ("JSUBJECTID", value, null, "/");
alert("first try made it here ");
frm.action = "acms/int/intakeHistory.do?function=getInt";
frm.submit();
alert("dam I am here");



ACTION
<action path="/getassignsum"
type="com.test.web.struts.int.IntAssignummaryAction"
name="IntAssignummaryActionForm"
validate="false"
input="/assignmentsum.do"
scope="request">
<forward name="success" path="/assignmentsum.do"/>
<forward name="accessdenied" path="/toregistry.do?prefix=&amp;page=/accessdenied.do"/>
</action>

FORM
<html:javascript formName="IntAssignummaryActionForm"/>
<script language="JavaScript">

window.onload = function()
{
setInputFocus("fromDateAsString");
}
</script>
<script language="JavaScript">


function isSubjectConsolidated(consolidatedToPDJ)
{


if(consolidatedToPDJ != 'N/A')
{
var msg='This minor has been consolidated with '+ consolidatedToPDJ +'. Please search for this minor under '+ consolidatedToPDJ;
alert(msg);
return true;
}
return false;
}


function setSubjectId (value,consolidatedToPDJ)
{

if(isSubjectConsolidated(consolidatedToPDJ))
{

return false;
}

var cookie = getCookie("GETSUBJECTID");

if (cookie == null){
deleteCookie("JSUBJECTID");
setCookie ("JSUBJECTID", value, null, "/");
alert("first try made it here ");
frm.action = "acms/int/intakeHistory.do?function=getInt";
frm.submit();
alert("dam I am here");
}
else
{
setCookie ("COMPANIONSUBJECTID", value, null, "/");
}
alert("made it here ");
/* return true; */
frm.action = "acms/int/intakeHistory.do?function=getInt";
frm.submit();
alert("what happen. I am suppose to be gone");
}

function getSubjectId ()
{
return getCookie ("JSUBJECTID");
}

function deleteSubjectId ()
{
deleteCookie ("JSUBJECTID");
}


</script>

<c:set var="SCREEN_TITLE" value="Intake Assignment Summary" scope="request"/>
<html:form action="/getassignsum.do">

Howard
 
The above work when I change used document.formname.action and document.formname.submit instead of frm.action and frm.submit.

I tested it with a hardcoded action. Now I want to pass in the action but need to know how do I
concatenate " with the action.

Meaning I want to see "acms/int/intakeHistory.do?function=getInt"

Not sure how to add "

I tried

String iLink = """ + LINK + """;

but this did not work


Howard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top