tags:

views:

319

answers:

2

I have some JavaScript that creates Forward and Back buttons. However, I need to pass a parameter in the URL (?id=$idd):

<a href="javascript:submitForm('mainForm','back');" title="Go back to the kit home page" style="float: left;"><img src="images/back.gif" alt="Go back to the kit home page" border="0" /></a>
<a href="javascript:submitForm('mainForm','proceed');" title="Submit the order details" style="float: right;"><img src="images/proceed.gif" alt="Proceed to the next page" border="0" /></a>

The JavaScript is below:

// Used in all pages to submit a form and optionally set a hidden 
// form varaible called 'navigate' to direct navgiation
function submitForm(formName, navigateValue) {
    if (navigateValue != null && navigateValue != "") {
     document.forms[formName].navigate.value = navigateValue;
    }
    document.forms[formName].submit();
}

Thanks.

A: 

You need to add the variable to the url your <form> points to:

<form action="example.com?id=14">
soulmerge
A: 

I'm guessing at what you're asking, and it doesn't make much sense because if you're submitting a form, why wouldn't you put the data in the form, but it sounds like you just need to modify the forms' action property. Something like:

document.forms[formName].action += "?id=$idd";

But this depends strongly on the existing action value and you will probably want to sanitise that with a validating method.

annakata