Page 1 of 1

how to handle multipe textbox using PHP

Posted: Thu Jun 02, 2005 1:09 am
by shseraj
Dear all,

I'm facing a problem to handle multiple textbox. I'm using two textbox with the same name. And a button, onclick that button it will take to a php page where i can retrive values given in the textbox in first page. I just want to pass all the data given in the buttonchk.htm to the next page buttonrcv.php by using array. I tried with the name="remark[]" but it says error in page. Please help me out!

buttonchk.htm:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html><head><title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head><body>

<input name="remarks" type="text" size="20" maxlength="200">

<input name="remarks" type="text" size="20" maxlength="200">

<button style="background:#FFFFFF;width:50" onClick="window.location.href='buttonrcv.php?remarks='+remarks.value">Done</button>

</body></html>


buttonrcv.php:

<html><head><title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head>
<body>
<?php

$remark[] = $_GET["remarks"];

echo $remark[0];
echo $remark[1];
?>
</body></html>



Reagrds
poor Sahrear

Posted: Thu Jun 02, 2005 1:39 am
by shiznatix
first, use php code tags

second, use forms instead of javascript

Code: Select all

&lt;form action=&quote;page2.php&quote; method=&quote;get&quote;&gt;
&lt;input type=&quote;text&quote; name=&quote;some_name&#1111;]&quote;&gt;
&lt;input type=&quote;text&quote; name=&quote;some_name&#1111;]&quote;&gt;
&lt;/form&gt;
then on page2.php

Code: Select all

print_r($_GET[some_name]);
bam there is your array on the 2nd page

Posted: Thu Jun 02, 2005 1:44 am
by Burrito
post your code within code or php tags you should.

much easier to read it is:

buttonchk.htm:

Code: Select all

&lt;!DOCTYPE HTML PUBLIC \&quote;-//W3C//DTD HTML 4.01 Transitional//EN\&quote;&gt; 

&lt;html&gt;&lt;head&gt;&lt;title&gt;Untitled Document&lt;/title&gt; 
&lt;meta http-equiv=\&quote;Content-Type\&quote; content=\&quote;text/html; charset=iso-8859-1\&quote;&gt;&lt;/head&gt;&lt;body&gt; 

&lt;form name=\&quote;MyForm\&quote;&gt;
&lt;input name=\&quote;remarks&#1111;]\&quote; type=\&quote;text\&quote; size=\&quote;20\&quote; maxlength=\&quote;200\&quote;&gt; 

&lt;input name=\&quote;remarks&#1111;]\&quote; type=\&quote;text\&quote; size=\&quote;20\&quote; maxlength=\&quote;200\&quote;&gt; 

&lt;button style=\&quote;background:#FFFFFF;width:50\&quote; onClick=\&quote;location='date.php?remarks='+document.MyForm.remarks&#1111;].value\&quote;&gt;Done&lt;/button&gt; 
&lt;/form&gt;

&lt;/body&gt;&lt;/html&gt;
buttonrcv.php:

Code: Select all

<html><head><title>Untitled Document</title> 
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\"></head> 
<body> 
<?php 
echo $_GET['remarks'][0]; 
echo $_GET['remarks'][1]; 
?> 
</body></html>
works this does with FF, tested with IE I have not.

edit: why I want to know does the board now escape all slashes in code tags?

Posted: Thu Jun 02, 2005 2:05 am
by malcolmboston
sound like yoda, you do :lol:

Posted: Thu Jun 02, 2005 2:15 am
by patrikG
Yes, and php-tags shseraj must use!

Posted: Sat Jun 04, 2005 11:04 pm
by shseraj
Dear Burrito,

I think the solution you posted does not work with IE. I need a solution for IE. And the Web server is IIS. I hope you understand my problem. Please reply me soon.

Kind Regards
Sahrear

Posted: Sun Jun 05, 2005 9:47 am
by Skara
I don't know what the deal with all this js is. O.o

Code: Select all

<!DOCTYPE HTML PUBLIC \&quote;-//W3C//DTD HTML 4.01 Transitional//EN\&quote;> 
 
<html><head><title>Untitled Document</title> 
<meta http-equiv=\&quote;Content-Type\&quote; content=\&quote;text/html; charset=iso-8859-1\&quote;></head><body> 
 
<form name=\&quote;MyForm\&quote;>
<input name=\&quote;remarks&#1111;]\&quote; type=\&quote;text\&quote; size=\&quote;20\&quote; maxlength=\&quote;200\&quote;> 
 
<input name=\&quote;remarks&#1111;]\&quote; type=\&quote;text\&quote; size=\&quote;20\&quote; maxlength=\&quote;200\&quote;> 

<input style=\&quote;background:#FFFFFF;width:50\&quote; type=\&quote;submit\&quote; value=\&quote;Done\&quote; /> 
</form>
 
</body></html>

Posted: Sun Jun 05, 2005 1:18 pm
by Burrito
this worked fine for me in IE

Code: Select all

<?
if(isset($_GET['blah'])){
echo $_GET['bob'][0];
echo "<br>".$_GET['bob'][1];
echo "<br>".$_GET['bob'][2];
}
?>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
	<title>Untitled</title>
</head>

<body>
<form method="get">
<input type="text" name="bob[]">
<input type="text" name="bob[]">
<input type="text" name="bob[]">
<input type="submit" name="blah">
</form>


</body>
</html>