/    Sign up×
Community /Pin to ProfileBookmark

One submit button with choice of two actions

Hello,

Thanks for the opportunity to ask for help on your forum. I hope you can help me with the following:

I’ve searched many posts dealing with the use of one form and two actions, but none of them seem to apply to what I’m trying to do, and I don’t have the skill to alter them.

I run my own website search engine to search my site, but I’d like to add two
bakecookie buttons to the search form labeled “website search” and “google search;” to switch between two actions; the default action to search my site…

<FORM METHOD=”get” ACTION=”mysite/mysearchengine.php”>
<div>
<INPUT NAME=”s”

and the second action (if chosen with the other bakecookie) to be…

<FORM METHOD=”get” ACTION=”http://www.google.com/search“>
<div>
<INPUT NAME=”q”

Would you please show me how to combine these two actions to work from the same form submit button?

Thanks,

Jeremy

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@harrierdhJan 29.2010 — Hard to tell what exactly you are trying to do. Let's see if I can give you a nudge. First use lower case on your tags. Second use an id and name for easier reference. I didn't test this but I think you will get the idea.

<script>

function sendForm() {

var temp = document.getElementById("text1").value;

if (temp == "a") {

document.getElementById("form1").action = "http://mysite1.php";

document.getElementById("form1").submit();

} else if (temp == "b") {

document.getElementById("form1").action = "http://mysite2.php";

document.getElementById("form1").submit();

}

</script>

<form name="form1" id="form1" method="get" action="http://mysite1.php">

<input type="text" name="text1" id="text1" value="" />

<input type="button" name="btn1" id="btn1" value="CLICK" onClick="sendForm()" />

</form>
Copy linkTweet thisAlerts:
@JeremyTauthorJan 30.2010 — Thanks for your reply. I'm afraid I don't have enough coding skill to make it work. If you could please help me further, I'll try to clarify with image below:

<img>http://img687.imageshack.us/i/searchmockup.jpg</img>

I'd like to give my visitors the default option to either search my website with my own search engine link (search.php ), or the internet, with the google link(http://www.google.com/search/), by having them check one or the other checkbox (or radio buttons) to make the choice.

Thanks again,

Jeremy
Copy linkTweet thisAlerts:
@JeremyTauthorJan 31.2010 — Thanks anyway... I was able to get help with the code on another forum.
×

Success!

Help @JeremyT spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...