Hi,

I have two forms:

one which displays the list of projects in a dropdown box from mysql db
second one is a date picker form.
after this i have a submit button.
Now, when i click the submit button I want to get the details of the Users corresponding to the project and the date.

My problem is i don't know how to activate the submit button to fetch both the values, in order to activate another PHP file which contains the code for selecting .

Thanx in advance

Recommended Answers

All 11 Replies

I think that you need two select buttons and process them one at a time; or; make the two forms into one. Why does the date picker need to be a separate form?

It is possible to use no submit buttons and instead just have a regular button <input type="button" and use a javascript function onclick to submit the two forms. An example is as follows.

<script>
function sender() {
document.forms["form1"].submit();
document.forms["form2"].submit();
return true;
}
</script>
<form id="form1">
<input type="text" value="test" name="test1">
</form>
<form id="form2">
<input type="text" value="test" name="test2">
</form>
<input type="button" onclick=javascript:sender()>

Hi,

I tried your concept, but i am stuck.

When i click the button I want to invoke another PHP script, How do i do that?

Thankyou.

It is possible to use no submit buttons and instead just have a regular button <input type="button" and use a javascript function onclick to submit the two forms. An example is as follows.

<script>
function sender() {
document.forms["form1"].submit();
document.forms["form2"].submit();
return true;
}
</script>
<form id="form1">
<input type="text" value="test" name="test1">
</form>
<form id="form2">
<input type="text" value="test" name="test2">
</form>
<input type="button" onclick=javascript:sender()>

If you mean to redirect to another page then that will start to get complex. You would need to gather all of the form variables into a javascript array (or id's eg getElementById) then submit that array as an ajax request to a php page and use javascript to redirect to another page.

Hi,

I tried your concept, but i am stuck.

When i click the button I want to invoke another PHP script, How do i do that?

Thankyou.

@kuteinhart... why not put both inputs into one form.. once you press submit, the form either goes back to the same page to do some processing or send these to another page.. either way.. you could do it like this..

if(isset($_POST['submit']))
{
   $first_var=$_POST['test1'];
   $second_var=$_POST['test2'];
   // you can now either use these for processing or for passing onto another page.

// - to pass these two variables to another page.. you can:
$url = "anotherpage.php?var1=".$first_var."&var2=".$second_var;            // target of the redirect
$delay = "0";                                                             // seconds delay
echo '<meta http-equiv="refresh" content="'.$delay.';url='.$url.'">';
die();
// - to access these two variables in anotherpage.php 
// you can assign them to variables as follows:
// $passedvar1=$_REQUEST['var1'];
// $passedvar2=$_REQUEST['var2'];
//	
}
<form id="form1" method="post" action="<?php echo $_SERVER['php_self'];?>">
<input type="text" value="test" name="test1">
<input type="text" value="test" name="test2">
</form>
<input type="button" name="submit" value="submit">

Do we need to put the submit button outside the form tags? I don't think its going to work.

why don't you use ajax?

Member Avatar for rajarajan2017

One form will accomadate only one submit button.

I would like users of my directory to submit their website details through my submit form to my database and goto PayPal at the same time (which is another from) I just want to use one button for this. I would rather not use java if possible because of browser compatability... Is the above code my best option? re: cwarn23 reply
Thankx in advance

@ROB65MAC65
just have your submit take you to your form handling script which in turn will use a header re-direct when it has finished.

@kuteinheart
use ajax for this. there is a tutorial here

u can give this
<form name="formname" method="get" action="filename.php">
and give a submit button , i hope nw it works.....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.