Skip to content Skip to sidebar Skip to footer

Form With 2 Submit Buttons

I have one form with 2 submit buttons. The form generates a URL. The 2 outputs of the form are: It writes a URL to a hidden div which displays when they click the Preview button,

Solution 1:

You can't get 'results' in the manner you're attempting. You'll need to try getting it via the ID reference, something like the following:

<form name="myForm" onSubmit="return myfunction();">
    <input  type="text"id="firstfield" name="firstfield"/>
    ... repreated 7 more times...
    <input type="submit" value="Preview"/>
    <input type="submit" onClick="window.open(document.getElementById('firstField').value + '/' + document.getElementById('results').value);" value="Open"/>
</form>
/* Hidden DIV */
<div id="results">
</div>

EDIT: And to make sure window.open doesn't think its a relative URL, ensure it starts with a protocol, eg http:// or https://.

Post a Comment for "Form With 2 Submit Buttons"