Page 1 of 1
PHP Help
Posted: Tue Jan 18, 2011 3:49 am
by moinshaikh
Hi all,
I am new to PHP Development. I am developing an online application "Cyber Manager" for cyber cafe management system. I have following query.
I have designed a page to add custoemer's details to database. Uppon successful registration, mysql DB will generate an ID (auto generated field). This add-customer.php form asks for some details like first name, last name, etc. Now i have a field named "ID Proof" (this is a select list - which have options like: driving license, Passport and Election Card) now i wish code for this. I want this form to generate another text box(called Expiry Date) if the input of ID Proof is either driving license or passport and if option is selected as Election Card, no another text field (i.e. exp. date) will be generated.
So i want to do this , but don't know how another filed is generated upon value of selection of its upper field.
Thank you in advance
Moin
Re: PHP Help
Posted: Tue Jan 18, 2011 4:17 am
by Peter Kelly
Just create the form field in HTML and the Database but use CSS to hide it by default and then use javascript/ajax to show/hide it on demand.
Re: PHP Help
Posted: Tue Jan 18, 2011 9:41 pm
by moinshaikh
Thank you Peter, thank you very much. I am now trying your idea 'll get back to you after having completed this.
Moin
Re: PHP Help
Posted: Tue Jan 18, 2011 10:05 pm
by moinshaikh
Dear Peter,
I have found a piece of JS code on net, it works fine, and its what i was looking for but only thing is that it hides/shows a field upon selection/deselection of checkbox while i want it to work upon selection of a particular option of a <select></select> element.
Can you help me what to write instead of that"document.frm.chkbox.
checked"
Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script language="JavaScript">
function showhidefield()
{
if (document.frm.chkbox.checked)
{
document.getElementById("hideablearea").style.visibility = "visible";
}
else
{
document.getElementById("hideablearea").style.visibility = "hidden";
}
}
</script>
</head>
<body>
<form name='frm' action='cpanel.php'>
<input type="checkbox" name="chkbox" onclick="showhidefield()">
Check/uncheck here to show/hide the other form fields
<br>
<div id='hideablearea' style='visibility:hidden;'>
<input type='text' name="txt"><br>
<input type='submit'>
</div>
This is a text line below the hideable form fields.<br>
</form>
</body>
</html>
Re: PHP Help
Posted: Wed Jan 19, 2011 1:08 am
by Peter Kelly
Erm I only know extremely basic Javascript but I guess the big I'm looking at is simpleish something like this should work
Code: Select all
if (document.frm.FORMFIELD.value == ""){
Try something like that.
Re: PHP Help
Posted: Wed Jan 19, 2011 4:51 am
by moinshaikh
Thank you very much peter, the problem is solved now. Hope u 'll stay in touch.

Time Calculation in PHP
Posted: Tue Jan 25, 2011 7:42 am
by moinshaikh
Hi all,
I am developing an application that takes times (login time and logout time) as input and generates total surfing time(in hh:mm), i have a form for that. The form has field as in-time, out time and surfing time. in time will store login time in mysql and out time will store logout time in mysql DB and after having subtracted in_time from out_time, system will automatically generate surfing_time and it'll be stored in surfing_time field of mysql DB. Now question is how can i calculate surfing time (means how do i write code in php and where from which this thing will be done)