Jump to content

post input from multiple forms


ann

Recommended Posts

Hi

I have a user input html page with multiple forms because the javascript won't work with one form or sub froms. My aim is to get the input data to a php script and I think the way to do that is have a final form in the html which posts all the input.

Problem, how do I get the input values from other forms into the final 'submit' from?  (don't remember where I got the syntax that I've commented out but it doesn't work anyway).  ???

Many thanks if you can help.

http://www.nematodes.org/test_js5.shtml

My scripts

html
[code]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<style type="text/css"> <!--.show {display:block;}.hide {display:none;}--></style>
< script type="text/javascript"><!--
function checkChangeAll(){
if (document.buttonDemo.onOffButton.value==" Select all "){
document.buttonDemo.onOffButton.value=" Clear all ";
for (i=0; i<document.forms[0].length; i++){if(document.forms[0].elements[i].name.match(/org/)){document.forms[0].elements[i].checked = true;}}
}
else{
document.buttonDemo.onOffButton.value=" Select all ";
for (i=0; i<document.forms[0].length; i++){if(document.forms[0].elements[i].name.match(/org/)){document.forms[0].elements[i].checked = false;}}
}
}
//--></ script>

</head>
<body onload="checkChangeAll()";>

< script type="text/javascript"><!--
window.onload=function() {
obj=document.getElementById('abun')
obj.className='hide';
objs=document.getElementById('simi')
objs.className='hide';
rad=document.getElementsByTagName('input');
for(c=0;c<rad.length;c++) {
if(rad[c].name=='out') {
rad[c].onclick=function() {
if(this.value==0) {obj.className='show';objs.className='hide';}
else {obj.className='hide';objs.className='show';}
}
}
}
}//--></ script>


<table class="tablephp2">
<tr>
<td>
<form method="post" name="buttonDemo">  <!--form[0]-->
<table>
<tr height=20></tr>
<tr>
<td><div class="mainBig">Species to search</div></td>
<td>
<input type="Button" value=" Select all " name="onOffButton" onClick="checkChangeAll()">
</td>
</tr>
<tr height=20></tr>
<tr>
<td><input TYPE="checkbox" NAME="org[0]" value="ACC">Ancylostoma caninum</input></td>
<td><input TYPE="checkbox" NAME="org[1]" value="ALC">Ascaris lumbricoides</input></td>
<td><input TYPE="checkbox" NAME="org[2]" value="ASC">Ascaris suum</input></td>
<td><input TYPE="checkbox" NAME="org[3]" value="AYC">Ancylostoma ceylanicum</input></td>
</tr><tr>
<td><input TYPE="checkbox" NAME="org[4]" value="BMC">Brugia malayi</input></td>
<td><input TYPE="checkbox" NAME="org[5]" value="DIC">Dirofilaria immitis</input></td>
<td><input TYPE="checkbox" NAME="org[6]" value="GPC">Globodera pallida</input></td>
<td><input TYPE="checkbox" NAME="org[7]" value="GRC">Globodera rostochiensis</input></td>
</tr><tr>
<td><input TYPE="checkbox" NAME="org[8]" value="HCC">Haemonchus contortus</input></td>
<td><input TYPE="checkbox" NAME="org[9]" value="HGC">Heterodera glycines</input></td>
<td><input TYPE="checkbox" NAME="org[10]" value="HSC">Heterodera schachtii</input></td>
<td><input TYPE="checkbox" NAME="org[11]" value="LSC">Litomosoides sigmodontis</input></td>
</tr>
<tr height=20></tr>
</table>
</form>
</td>
</tr>
<tr>
<td>
<form method="post" action="#"><!--form[1]-->
<table width=100%>
<tr>
<td width=30%>
<div><div class="mainBig">Output by:</div>
<label><input type="radio" name="out" value=0 /> table of clusters</label><br>
<label><input TYPE="radio" NAME="out" VALUE=1 /> as SimiTri</label><br>
</div>
</td>
<td valign=top>
<div id="abun">
<table width=100%>
<tr>
<td width=30%><div class="mainBig">Order results by</div></td>
<td width=30%><div class="mainBig">Report</div></td>
</tr>
<tr>
<td><input TYPE="radio" NAME="order" VALUE="0" checked>sequence abunance</td>
<td><input TYPE="radio" NAME="hits" VALUE="0" checked>all hits</td>
</tr>
<tr>
<td><input TYPE="radio" NAME="order" VALUE="1" >blast score</td>
<td><input TYPE="radio" NAME="hits" VALUE="1">1st hit only</td>
</tr>
</table>
</div>
<div id="simi">
<table width=100%>
<tr><td><div class="mainBig">SimiTri data type</div></td></tr>
<tr><td><input TYPE="radio" NAME="datatype" VALUE="0" checked>bit score</td></tr>
<tr><td><input TYPE="radio" NAME="datatype" VALUE="1">expression</td></tr>
</table>
</div>
</td>
</tr>
</table>
</form>
</td>
</tr>
<tr height=20></tr>
<tr>
<td colspan=3 valign=top>
<form method="post" action="test.php">
<!-- <input type="hidden" name="org" value=forms[0]>
<input type="hidden" name="out" value="forms[1].out">-->
<center><input TYPE="submit" VALUE="Search"></center>
</form>
</td>
</tr>
</table>
</body>
</html>
[/code]

test.php
[code]<?php
$orgs=$_POST['org'];  #read the org (organisms) array
$output=$_POST['out']; 

$orgs2=array("a","b","c","d");
print "<!doctype html public \"-//w3c//dtd html 4.0 transitional//en\">";
print "<html>\n<head>\n</head>\n<body><br><center>";
print "output => $output <br> orgs=>    ";
print_r($orgs);
print "<br>testarray=>    ";
print_r($orgs2);
?>
[/code]
Link to comment
Share on other sites

becasue the javascript wont work! Well not for me but if anyone would like to tell me how to make it work on one form that would be great too.

The javascript for selecting output type is fine in one form but the "select all" button javascript requires an object called document.buttonDemo which I've difened in the form tag  <form method="post" name="buttonDemo">

So is there a way to defiine document.buttonDemo without using a form tag ?
Link to comment
Share on other sites

No solution but I've got to get on so I changed the button to a check box which means I can work the javascript in one form.

the code
[code]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
< script type="text/javascript"><!--
function checkAll(){
  for (i=0; i<document.forms[0].length; i++)
      if(document.forms[0].elements[i].name=="org[]") document.forms[0].elements[i].checked = true
}
function clearAll(){
  for (i=0; i<document.forms[0].length; i++)
      if(document.forms[0].elements[i].name=="org[]") document.forms[0].elements[i].checked = false
}//-->< /script>
</head>
<body>

<style type="text/css"> <!--.show {display:block;}.hide {display:none;}--></style>
< script type="text/javascript"><!--
window.onload=function() {
obj=document.getElementById('abun')
obj.className='hide';
objs=document.getElementById('simi')
objs.className='hide';
rad=document.getElementsByTagName('input');
for(c=0;c<rad.length;c++) {
if(rad[c].name=='out') {
rad[c].onclick=function() {
if(this.value==0) {obj.className='show';objs.className='hide';}
else {obj.className='hide';objs.className='show';}
}
}
}
}
//-->< /script>

<form method="post" action="annotation_search.php">
<table class="tablephp2">
<tr>
<td>
<table>
<tr height=20></tr>
<tr>
<td><div class="mainBig">Species to search</div></td>
<td>
<input type=checkbox onClick="if(this.checked)checkAll(); else clearAll()"> sellect all
</td>
</tr>
<tr height=20></tr>
<tr>
<td><input TYPE="checkbox" NAME="org[]" value="ACC">Ancylostoma caninum</input></td>
<td><input TYPE="checkbox" NAME="org[]" value="ALC">Ascaris lumbricoides</input></td>
<td><input TYPE="checkbox" NAME="org[]" value="ASC">Ascaris suum</input></td>
<td><input TYPE="checkbox" NAME="org[]" value="AYC">Ancylostoma ceylanicum</input></td>
</tr><tr>
<td><input TYPE="checkbox" NAME="org[]" value="BMC">Brugia malayi</input></td>
<td><input TYPE="checkbox" NAME="org[]" value="DIC">Dirofilaria immitis</input></td>
<td><input TYPE="checkbox" NAME="org[]" value="GPC">Globodera pallida</input></td>
<td><input TYPE="checkbox" NAME="org[]" value="GRC">Globodera rostochiensis</input></td>
</tr><tr>
<td><input TYPE="checkbox" NAME="org[]" value="HCC">Haemonchus contortus</input></td>
<td><input TYPE="checkbox" NAME="org[]" value="HGC">Heterodera glycines</input></td>
<td><input TYPE="checkbox" NAME="org[]" value="HSC">Heterodera schachtii</input></td>
<td><input TYPE="checkbox" NAME="org[]" value="LSC">Litomosoides sigmodontis</input></td>
</tr>
<tr height=20></tr>
</table>
<table width=100%>
<tr>
<td width=30%>
<div><div class="mainBig">Output by:</div>
<label><input type="radio" name="out" value=0 /> table of clusters</label><br>
<label><input TYPE="radio" NAME="out" VALUE=1 /> as SimiTri</label><br>
</div>
</td>
<td valign=top>
<div id="abun"><table width=100%>
<tr>
<td width=30%><div class="mainBig">Order results by</div></td>
<td width=30%><div class="mainBig">Report</div></td>
</tr>
<tr>
<td><input TYPE="radio" NAME="order" VALUE="0" checked>sequence abunance</td>
<td><input TYPE="radio" NAME="hits" VALUE="0" checked>all hits</td>
</tr>
<tr>
<td><input TYPE="radio" NAME="order" VALUE="1" >blast score</td>
<td><input TYPE="radio" NAME="hits" VALUE="1">1st hit only</td>
</tr>
</table></div>
<div id="simi"><table width=100%>
<tr><td><div class="mainBig">SimiTri data type</div></td></tr>
<tr><td><input TYPE="radio" NAME="datatype" VALUE="0" checked>bit score</td></tr>
<tr><td><input TYPE="radio" NAME="datatype" VALUE="1">expression</td></tr>
</table></div>
</td>
</tr>
<tr height=20></tr>
<tr>
<td colspan=3 valign=top>
<center><input TYPE="submit" VALUE="Search"></center>
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</body>
</html>[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.