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
PHP Help
Moderator: General Moderators
-
Peter Kelly
- Forum Contributor
- Posts: 143
- Joined: Fri Jan 14, 2011 5:33 pm
- Location: England
- Contact:
Re: PHP Help
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.
-
moinshaikh
- Forum Commoner
- Posts: 27
- Joined: Tue Jan 18, 2011 3:40 am
- Location: India
Re: PHP Help
Thank you Peter, thank you very much. I am now trying your idea 'll get back to you after having completed this.
Moin
Moin
-
moinshaikh
- Forum Commoner
- Posts: 27
- Joined: Tue Jan 18, 2011 3:40 am
- Location: India
Re: PHP Help
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"
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>
Last edited by Benjamin on Tue Jan 18, 2011 10:07 pm, edited 1 time in total.
Reason: Added [syntax=html] tags.
Reason: Added [syntax=html] tags.
-
Peter Kelly
- Forum Contributor
- Posts: 143
- Joined: Fri Jan 14, 2011 5:33 pm
- Location: England
- Contact:
Re: PHP Help
Erm I only know extremely basic Javascript but I guess the big I'm looking at is simpleish something like this should work
Try something like that.
Code: Select all
if (document.frm.FORMFIELD.value == ""){-
moinshaikh
- Forum Commoner
- Posts: 27
- Joined: Tue Jan 18, 2011 3:40 am
- Location: India
Re: PHP Help
Thank you very much peter, the problem is solved now. Hope u 'll stay in touch. 
-
moinshaikh
- Forum Commoner
- Posts: 27
- Joined: Tue Jan 18, 2011 3:40 am
- Location: India
Time Calculation in PHP
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)
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)