Forum Moderators: coopster

Message Too Old, No Replies

Form refresh with checkbox

         

andrew123

7:43 pm on Jul 20, 2005 (gmt 0)

10+ Year Member



what i have is

a normal form without requirement fields

if the user check the checkbox the page will reload and the form fields now will be require

this is what i have but i got error

anyone see what i do wrong

<?php
//this is a bit of javascript too...
?>
<script>
function refreshstuff()
{
document.myform.foo2.value="changed";
document.myform.submit();
}

</script>

<form name="myform">
<input type="checkbox" name="foo2" value="checkbox" onChange="refreshstuff();">
<input size="35" name="Email" VALUE maxlength="60">

<?php
if($foo2 == "changed")
{
//....refresh form with requirements

<form name="myform">
<input type="checkbox" name="foo2" value="checkbox">
<input size="35" name="Email" VALUE maxlength="60">
}
?>

ergophobe

7:53 pm on Jul 20, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Welcome to WebmasterWorld Andrew.

What error message did you get?

dreamcatcher

7:58 pm on Jul 20, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I`m guessing that having this:

<form name="myform">
<input type="checkbox" name="foo2" value="checkbox">
<input size="35" name="Email" VALUE maxlength="60">

in an if statement is going to cause a problem as you aren`t echoing or printing the data. You need to use:

<?php
if($foo2 == "changed")
{
//....refresh form with requirements
?>
<form name="myform">
<input type="checkbox" name="foo2" value="checkbox">
<input size="35" name="Email" VALUE maxlength="60">
<?php
}
?>

dc

andrew123

8:03 pm on Jul 20, 2005 (gmt 0)

10+ Year Member



oh hi ergophobe, thanks for the welcome

this is the error i got

Parse error: syntax error, unexpected T_LNUMBER, expecting ',' or ';' in D:\Inetpub\wwwroot\TBSSite\php\modulus_quote.php on line 1085

oh imgoing to try waht dreamcacher said see if it will solve problem

thanks guys

mcibor

9:57 pm on Jul 20, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Moreover specify action and method in <form :

<?php
//...
?>
<form name="myform" method="POST" action="<?php echo $SERVER["PHP_SELF"];?>">
<<input type="checkbox" name="foo2" value="checkbox" onChange="refreshstuff();">
<input size="35" name="Email" VALUE maxlength="60">

<?php
if($_POST["foo2"] == "changed")
{
//....refresh form with requirements
?>
<form name="myform" method="POST" action="<?php echo $SERVER["PHP_SELF"];?>">
<input type="checkbox" name="foo2" value="checkbox">
<input size="35" name="Email" VALUE maxlength="60">
<?php
}
?>

Best regards
Michal Cibor