You are totally correct in your assumption and thanks so much for the quick and terrific answer! Your direct value code is certainly shorter and clearer and I suspect faster!
I have tried it and it comes back to the same page I just deleted the form action="greeting.cfm" (nextpage) and added form onSubmit="chooseAction(doc
I really appreciate your assistance!!!
Betty
Main Topics
Browse All Topics





by: tmcneerPosted on 2006-03-06 at 14:32:20ID: 16119376
Betty,
e" or whatever the correct identifier of the field is) and place it inside a function which is called when the form is submitted.
;'
ument.form .layout.va lue);
Basically, you want to take your example code (referring to the "layout" field correctly -- something like "document.form.layout.valu
So you might have:
function chooseAction() {
(Your coditional code goes here)
}
Then in either your form tag or your submit button tag, place 'onSubmit="chooseAction()"
That will fire the script and change the action before the actual page request is made.
You could also use the "layout" value within the onSubmit function, making things simpler:
Thus:
onSubmit="chooseAction(doc
That will pass the layout value directly into your function. Then the function could look like:
function chooseAction(layoutValue) {
document.form.action = "greeting" + layoutValue + ".cfm";
}
If you write the script with conditional logic, as you have it in your post, remember that in javascript, comparison requires a double equals sign.
"if (layout == 1) " not "if (layout=1)"
And "elseif" is not one word in javascript. It's "else if."
By the way, I'm assuming that in your example "greeting1" and "nextpage1" are equivalents. If you were really trying to work with two different sets of page names, I've misunderstood what you're asking.
Tom