PHP Form Not Displaying With jQuery Mobile - php

Part of my PHP form is not displaying with jQuery Mobile. The form seems to cut off after <input name="F_Payment_Preference" type="hidden" id="F_Payment_Preference" value="check"> and then it restarts after </form>. My form seems to function and display correctly without jQuery Mobile. I am not showing the head of the page (it's in a separate file), but I don't think that is necessary.
">
<form action="<? echo $_SERVER["PHP_SELF"] ?>" method="post" name="form1" id="form1" onsubmit="return CheckData();">
<h1><? echo PERSONAL_INFORMATION
?></h1><?
if ($show_sponsor == 1) {
Get_Sponsor_Cookie('name');
}
?>
<div>
*<? echo REQUIRED_FIELDS
?>
</div>
<div>
<label for="F_First_Name"><? echo FIRST_NAME
?>*</label>
<input name="F_First_Name" type="text" value="<? echo $F_First_Name ?>" maxlength="50">
<div id="divfname" style="display:none;">
<? echo JV_ENTER_FIRST_NAME
?>
</div>
</div>
<div>
<label for="F_Last_Name"><? echo LAST_NAME ?>*</label>
<input name="F_Last_Name" type="text" value="<? echo $F_Last_Name ?>" maxlength="50">
</div>
<div id="divlname" style="display:none">
<? echo JV_ENTER_LAST_NAME
?>
</div>
<?
if ($require_company == 1 || $require_company == 2)
{
?>
<div>
<label for="F_Company_Name"><? echo ROW_COMPANY ?>
<?
if ($require_company == 2) { echo "*";
}
?></label>
<input name="F_Company_Name" type="text" value="<? echo $F_Company_Name ?>" maxlength="100">
</div>
<div id="divcmp" style="display:none">
<? echo ENTER_COMPANY
?>
</div>
<?
}
if ($require_address_1 == 1 || $require_address_1 == 2)
{
?>
<div>
<label for="F_Address_1"><? echo ADDRESS_1
?><?
if ($require_address_1 == 2) { echo "*";
}
?></label>
</div>
<input name="F_Address_1" type="text" value="<? echo $F_Address_1 ?>" maxlength="200">
<div id="divaddr1" style="display:none">
<? echo JV_ENTER_ADDRESS_1
?>
</div>
<?
}
if ($require_address_2 == 1 || $require_address_2 == 2)
{
?>
<div>
<label for="F_Address_2"><? echo ADDRESS_2
?><?
if ($require_address_2 == 2) { echo "*";
}
?></label>
<input name="F_Address_2" type="text" value="<? echo $F_Address_2 ?>" maxlength="200">
</div>
<div id="divaddr2" style="display:none">
<? echo JV_ENTER_ADDRESS_2
?>
</div>
<?
}
if ($require_city == 1 || $require_city == 2)
{
?>
<div>
<label for="F_City"><? echo ROW_CITY
?><?
if ($require_city == 2) { echo "*";
}
?></label>
<input name="F_City" type="text" value="<? echo $F_City ?>" maxlength="50">
</div>
<div id="divcity" style="display:none">
<? echo JV_ENTER_CITY
?>
</div>
<?
}
if ($require_ste == 1 || $require_state == 2)
{
?>
<div>
<label for="F_State"><? echo ROW_STATE
?><?
if ($require_state == 2) { echo "*";
}
?></label>
<input name="F_State" type="text" value="<? echo $F_State ?>" maxlength="50">
</div>
<div id="divstate" style="display:none">
<? echo JV_ENTER_STATE
?>
</div>
<?
}
if ($require_country == 1 || $require_country == 2)
{
?>
<div>
<label><? echo ROW_COUNTRY
?><?
if ($require_country == 2) { echo "*";
}
?></label>
<?
if (!isset($_POST['F_Country'])) { $F_Country = '';
} else { $F_Country = $_POST['F_Country'];
} Country_Menu_Members($F_Country);
?>
</div>
<?
}
if ($require_zip == 1 || $require_zip == 2)
{
?>
<div>
<label for="F_Zip"><? echo ZIP_CODE
?><?
if ($require_zip == 2) { echo "*";
}
?></label>
<input name="F_Zip" type="text" value="<? echo $F_Zip ?>" maxlength="25" />
</div>
<div id="divzip" style="display:none">
<? echo JV_ENTER_ZIP
?>
</div>
<?
}
if ($require_phone == 1 || $require_phone == 2)
{
?>
<div>
<label for="F_Phone"><? echo PHONE
?><?
if ($require_phone == 2) { echo "*";
}
?></label>
<input name="F_Phone" type="text" value="<? echo $F_Phone ?>" maxlength="25" />
</div>
<div id="divphone" style="display:none">
<? echo JV_ENTER_PHONE
?>
</div>
<?
}
if ($require_fax == 1 || $require_fax == 2)
{
?>
<div>
<label for="F_Fax"><? echo FAX
?><?
if ($require_fax == 2) { echo "*";
}
?></label>
<input name="F_Fax" type="text" value="<? echo $F_Fax ?>" maxlength="25" />
</div>
<div id="divfax" style="display:none">
<? echo ENTER_FAX
?>
</div>
<?
}
if ($require_check_name == 1 || $require_check_name == 2)
{
?>
<div>
<label for="F_Check_Name"><? echo CHECK_NAME
?><?
if ($require_check_name == 2) { echo "*";
}
?></label>
<input name="F_Check_Name" type="text" value="<? echo $F_Check_Name ?>" maxlength="50" />
</div>
<div id="divcheckname" style="display:none">
<? echo ENTER_CHECK_NAME
?>
</div>
<?
}
if ($show_payment == 1)
{
?>
<div>
<label for="F_Payment_Preference"><? echo PAYMENT_PREFERENCE
?>*</label>
<? Link_Payment_Preferences();?>
<? } else {?>
<input name="F_Payment_Preference" type="hidden" id="F_Payment_Preference" value="check" />
</div>
<?
}
if ($require_tax_id == 1 || $require_tax_id == 2)
{
?>
<div>
<label for="F_Tax_ID"><? echo TAX_ID
?><?
if ($require_tax_id == 2) { echo "*";
}
?></label>
<input name="F_Tax_ID" type="text" value="<? echo $F_Tax_ID ?>" maxlength="50" />
</div>
<div id="divtax" style="display:none">
<? echo INVALID_TAX_ID
?>
</div>
<?
}
?> <h2><? echo USER_ACCOUNT_INFORMATION
?></h2>
<?
if ($require_username == 1 || $require_username == 2)
{
?>
<div>
<label for="F_User_Name"><? echo USERNAME
?>
<?
if ($require_username == 2) { echo "*";
}
?></label>
<input name="F_User_Name" type="text" value="<? echo $F_User_Name ?>" maxlength="20" />
</div>
<div id="divuname" style="display:none">
<? echo JV_ENTER_USERNAME
?>
</div>
<?
}
if ($require_password == 1 || $require_password == 2)
{
?>
<div>
<label for="F_Password"><? echo PASSWORD
?><?
if ($require_password == 2) { echo "*";
}
?></label>
<input name="F_Password" type="password" value="<? echo $F_Password ?>" maxlength="12">
</div>
<div id="divpw" style="display:none">
<? echo JV_ENTER_PASSWORD
?>
</div>
<div>
<label for="F_Password_2"><? echo CONFIRM_PASSWORD
?><?
if ($require_password == 2) { echo "*";
}
?></label>
<input name="F_Password_2" type="password" id="password2" value="<? echo $F_Password_2 ?>" maxlength="12">
</div>
<div id="divcpw" style="display:none">
<? echo JV_ENTER_CONFIRM_PASSWORD
?>
</div>
<?
}
?>
<div>
<label for="F_Primary_Email"><? echo EMAIL_ADDRESS
?>*</label>
<input name="F_Primary_Email" type="email" value="<? echo $F_Primary_Email ?>" maxlength="50">
</div>
<div id="divemail" style="display:none">
<? echo JV_ENTER_EMAIL
?>
</div>
<?
if ($require_paypal_email == 1 || $require_paypal_email == 2)
{
?>
<div>
<label for="F_Paypal_Email"><? echo PAYPAL_EMAIL
?><?
if ($require_paypal_email == 2) { echo "*";
}
?></label>
<input name="F_Paypal_Email" type="text" value="<? echo $F_Paypal_Email ?>" maxlength="50">
</div>
<div id="divpaypal" style="display:none">
<? echo JV_ENTER_PAYPAL
?>
</div>
<?
}
if ($require_stormpay_email == 1 || $require_stormpay_email == 2)
{
?>
<div>
<label for="F_Stormpay_Email"><? echo STORMPAY_EMAIL
?><?
if ($require_stormpay_email == 2) { echo "*";
}
?></label>
<input name="F_Stormpay_Email" type="text" value="<? echo $F_Stormpay_Email ?>" maxlength="50">
</div>
<div id="divstormpay" style="display:none">
<? echo JV_STORMPAY_EMAIL
?>
</div>
<?
}
if ($require_safepay_email == 1 || $require_safepay_email == 2)
{
?>
<div>
<label for="F_Safepay_Email"><? echo SAFEPAY_EMAIL
?><?
if ($require_stormpay_email == 2) { echo "*";
}
?></label>
<input name="F_Safepay_Email" type="text" value="<? echo $F_Safepay_Email ?>" maxlength="50">
</div>
<div id="divsafepay" style="display:none">
<? echo JV_SAFEPAY_EMAIL
?>
</div>
<?
}
if ($require_moneybookers_email == 1 || $require_moneybookers_email == 2)
{
?>
<div>
<label for="F_Moneybookers_Email"><? echo MONEYBOOKERS_EMAIL
?><?
if ($require_moneybookers_email == 2) { echo "*";
}
?></label>
<input name="F_Moneybookers_Email" type="text" value="<? echo $F_Moneybookers_Email ?>" maxlength="50">
</div>
<div id="divmoneybookers" style="display:none">
<? echo JV_MONEYBOOKERS_EMAIL
?>
</div>
<?
}
if ($require_alertpay_email == 1 || $require_alertpay_email == 2)
{
?>
<div>
<label for="F_Alertpay_Email"><? echo ALERTPAY_EMAIL
?><?
if ($require_alertpay_email == 2) { echo "*";
}
?></label>
<input name="F_Alertpay_Email" type="text" value="<? echo $F_Alertpay_Email ?>" maxlength="50">
</div>
<div id="divalertpay" style="display:none">
<? echo JV_ALERTPAY_EMAIL
?>
</div>
<?
}
if ($require_egold_id == 1 || $require_egold_id == 2)
{
?>
<div>
<label for="F_Egold_Id"><? echo EGOLD_ID
?><?
if ($require_egold_id == 2) { echo "*";
}
?></label>
<input name="F_Egold_Id" type="text" value="<? echo $F_Egold_Id ?>" maxlength="50">
</div>
<div id="divegold" style="display:none">
<? echo JV_EGOLD_ID
?>
</div>
<?
}
if ($require_bank_transfer == 1 || $require_bank_transfer == 2)
{
?>
<div>
<label for="F_Bank_Transfer"><? echo BANK_TRANSFER
?><?
if ($require_bank_transfer == 2) { echo "*";
}
?></label>
<textarea name="F_Bank_Transfer" cols="30" rows="3"><? echo $F_Bank_Transfer ?></textarea>
</div>
<div id="divbanktransfer" style="display:none">
<? echo JV_BANK_TRANSFER
?>
</div>
<?
}
if ($require_sponsor == 1)
{
if (empty($_COOKIE['jrox']))
{
?>
<div>
<label for="F_Sponsor"><? echo REFERRAL_CODE
?>*</label>
<input name="F_Sponsor" type="text" value="<? echo $F_Sponsor ?>" maxlength="25">
</div>
<?
}
else
{
?>
<input name="F_Sponsor" type="hidden" id="F_Sponsor" value="<? echo $F_Sponsor ?>">
<div>
<?
}
}
else
{
?>
<input name="F_Sponsor" type="hidden" id="F_Sponsor" value="<? echo $F_Sponsor ?>">
</div>
<?
}
if ($require_website_url == 1 || $require_website_url == 2)
{
?>
<div>
<label><? echo WEBSITE_URL
?><?
if ($require_website_url == 2) { echo "*";
}
?></label>
<input name="F_Web_Site" type="text" value="<? echo $F_Web_Site ?>" maxlength="100">
</div>
<div id="divweb" style="display:none">
<? echo INVALID_WEBSITE_ADDRESS
?>
</div>
<?
}
if ($enable_custom_1 == 1 || $enable_custom_1 == 2)
{
?>
<div>
<label><? echo $custom_field_1
?><?
if ($enable_custom_1 == 2) { echo "*";
}
?></label>
<input name="F_Custom_Value_1" type="text" value="<? echo $F_Custom_Value_1 ?>" maxlength="255">
</div>
<div id="divcf1" style="display:none">
<? echo ROW_ENTER." ".$custom_field_1
?>
</div>
<?
}
if ($enable_custom_2 == 1 || $enable_custom_2 == 2)
{
?>
<div>
<label><? echo $custom_field_2
?><?
if ($enable_custom_2 == 2) { echo "*";
}
?></label>
<input name="F_Custom_Value_2" type="text" value="<? echo $F_Custom_Value_2 ?>" maxlength="255">
</div>
<div id="divcf2" style="display:none">
<? echo ROW_ENTER." ".$custom_field_2
?>
</div>
<?
}
if ($enable_custom_3 == 1 || $enable_custom_3 == 2)
{
?>
<div>
<label><? echo $custom_field_3
?><?
if ($enable_custom_3 == 2) { echo "*";
}
?></label>
<input name="F_Custom_Value_3" type="text" value="<? echo $F_Custom_Value_3 ?>" maxlength="255">
</div>
<div id="divcf3" style="display:none">
<? echo ROW_ENTER." ".$custom_field_3
?>
</div>
<?
}
if ($enable_custom_4 == 1 || $enable_custom_4 == 2)
{
?>
<div>
<label><? echo $custom_field_4
?> <?
if ($enable_custom_4 == 2) { echo "*";
}
?></label>
<input name="F_Custom_Value_4" type="text" value="<? echo $F_Custom_Value_4 ?>" maxlength="255">
</div>
<div id="divcf4" style="display:none">
<? echo ROW_ENTER." ".$custom_field_4
?>
</div>
<?
}
if ($enable_custom_5 == 1 || $enable_custom_5 == 2)
{
?>
<div>
<label><? echo $custom_field_5
?><?
if ($enable_custom_5 == 2) { echo "*";
}
?></label>
<input name="F_Custom_Value_5" type="text" value="<? echo $F_Custom_Value_5 ?>" maxlength="255">
</div>
<div id="divcf5" style="display:none">
<? echo ROW_ENTER." ".$custom_field_5
?>
</div>
<?
}
if ($enable_membership_payment == 2)
{
?>
<div>
<? echo MEMBERSHIP_FULL_AMOUNT
?>
<? echo $membership_full_amount
?>
<div>
<label><? echo SELECT_PAYMENT_TYPE
?></label>
</div>
<? List_Processor_Options();?>
<?
}
if ($enable_custom_html == 1 )
{
?>
<div>
<? echo $custom_html ?>
</div>
<?
}
if ($require_tos == 1 || $require_tos == 2)
{
?>
<div>
<input name="F_TOS" type="checkbox" id="F_TOS" value="1">
<?
if ($require_tos == 2) { echo "checked";
}
?>
</div>
<div>
<label><? echo ACCEPT_AND_WILL_FOLLOW ?></label><a href="<? echo MEMBERS_HOME_BASE_URL.HOME_BASE_AFFILIATE_DIRECTORY.'/index.php?req=tos&pid=$pid' ?>" target="_blank" data-role="dialog"><? echo TERMS_OF_SERVICE
?></a>
</div>
<?
}
?>
</div>
<div>
<input type="submit" name="Submit" value="<? echo SUBMIT?>">
<input name="req" type="hidden" id="req" value="newaccount">
<input name="action" type="hidden" id="action" value="signup">
<input name="pid" type="hidden" id="pid" value="<? echo $pid ?>">
</div>
</form>
<?
}
?>

It appears to be bad HTML formatting. I think you would be ok if you restructure the if block just above the problem area. This is what I see:
...
if ($show_payment == 1)
{
?>
<div>
<label>...</label>
<? Link_Payment_Preferences();?>
<? } else {?>
<input name="F_Payment_Preference" type="hidden" id="F_Payment_Preference" value="check" />
</div>
<?
}
...
Do you see the problem? If $show_payment == 1, you start a <div> but do not close it. If $show_payment != 1 (else) then you close an unopened <div>
UPDATE
So the answer is to better format your code:
...
if ($show_payment == 1)
{
?>
<div>
<label>...</label>
<? Link_Payment_Preferences();?>
</div>
<? } else {?>
<div>
<label>...</label>
<input name="F_Payment_Preference" type="hidden" id="F_Payment_Preference" value="check" />
</div>
<?
}
...
See the difference? We have to close that div in either branch your logic takes. Otherwise, jQuery Mobile may render some unexpected results as the DOM is not properly constructed.
Hope this helps.

Related

PHP third branch of if else statement not working properly

<!doctype html>
<?php
This is for setting cookies
//first failed attempt
if (isset($_POST['firstname']) != null || isset($_POST['lastname']) != null ||
isset($_POST['phonenumber']) != null || isset($_POST['email']) != null
|| isset($_POST['sulleyaddress']) != null || isset($_POST['question1']) != null
|| isset($_POST['question2']) != null || isset($_POST['question3']) != null
|| isset($_POST['question4']) != null || isset($_POST['question5']) != null) {
setcookie('firstname',$_POST['firstname']);
setcookie('lastname',$_POST['lastname']);
setcookie('phonenumber',$_POST['phonenumber']);
setcookie('email',$_POST['email']);
setcookie('sulleyaddress',$_POST['sulleyaddress']);
setcookie('question1',$_POST['question1']);
setcookie('question2',$_POST['question2']);
setcookie('question3',$_POST['question3']);
setcookie('question4',$_POST['question4']);
setcookie('question5',$_POST['question5']);
}
this is for reseting cookies
//second failed attempt
if (isset($_POST['firstname']) == null) {
setcookie('firstname','');
}
if (isset($_POST['lastname']) == null) {
setcookie('lastname','');
}
if (isset($_POST['phonenumber']) == null) {
setcookie('phonenumber','');
}
if (isset($_POST['email']) == null) {
setcookie('email','');
}
if (isset($_POST['sulleyaddress']) == null) {
setcookie('sulleyaddress','');
}
if (isset($_POST['question1']) == null) {
setcookie('question1','');
}
if (isset($_POST['question2']) == null) {
setcookie('question2','');
}
if (isset($_POST['question3']) == null) {
setcookie('question3','');
}
if (isset($_POST['question4']) == null) {
setcookie('question4','');
}
if (isset($_POST['question5']) == null) {
setcookie('question5','');
}
?>
<html>
<head>
<title>Assignment 2 - Anthony Taveras</title>
<style>#import url("css/styles.css");</style>
<!-- <link rel="stylesheet" href="styles.css" /> -->
</head>
<body>
<?php
1st step. Make the form appear. Allow user to enter and submit data.
if (!isset($_POST['submit'])) {
?>
<div id="content-container">
<div id="content">
<form name="form" id="form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<fieldset>
<legend>Please Fill Out the Form</legend>
<ol>
<li><input type="text" name="firstname" value="<?php if (isset($_COOKIE['firstname'])) {echo $_COOKIE['firstname'];} ?>" ><label> First Name</label></li>
<li><input type="text" name="lastname" value="<?php if (isset($_COOKIE['lastname'])) {echo $_COOKIE['lastname'];} ?>" ><label> Last Name</label></li>
<li><input type="text" name="phonenumber" value="<?php if (isset($_COOKIE['phonenumber'])) {echo $_COOKIE['phonenumber'];} ?>" ><label> Phone Number</label></li>
<li><input type="text" name="email" value="<?php if (isset($_COOKIE['email'])) {echo $_COOKIE['email'];} ?>" ><label> Email</label></li>
<li><input type="text" name="sulleyaddress" value="<?php if (isset($_COOKIE['sulleyaddress'])) {echo $_COOKIE['sulleyaddress'];} ?>" ><label> Sulley Address</label></li>
</ol>
</fieldset>
<fieldset>
<legend>Please answer these questions</legend>
<ol>
<li class="question"><input type="text" name="question1" value="<?php if (isset($_COOKIE['question1'])) {echo $_COOKIE['question1'];} ?>" ><label> What is your favorite color?</label></li>
<li class="question"><input type="text" name="question2" value="<?php if (isset($_COOKIE['question2'])) {echo $_COOKIE['question2'];} ?>" ><label> Where were you born?</label></li>
<li class="question"><input type="text" name="question3" value="<?php if (isset($_COOKIE['question3'])) {echo $_COOKIE['question3'];} ?>" ><label> What is your favorite food?</label></li>
<li class="question"><input type="text" name="question4" value="<?php if (isset($_COOKIE['question4'])) {echo $_COOKIE['question4'];} ?>" ><label> What is your favorite movie?</label></li>
<li class="question"><input type="text" name="question5" value="<?php if (isset($_COOKIE['question5'])) {echo $_COOKIE['question5'];} ?>" ><label> What is your favorite book?</label></li>
<li><input type="submit" name="submit" value="Submit" /></li>
</ol>
</fieldset>
</form>
</div>
</div>
2nd step once submitted user can view responses
<?php
} elseif (isset($_POST['submit'])) {
?>
<!--=============================================Form Preview--------------------------------------->
<div id="content-container">
<div id="content">
<h1> Here's what you put down</h1>
<p> First Name: <?php print $_POST['firstname']; ?> </p>
<p> Last Name: <?php print $_POST['lastname']; ?> </p>
<p> Phone Number: <?php print $_POST['phonenumber']; ?> </p>
<p> Email: <?php print $_POST['email']; ?> </p>
<p> Sulley Address: <?php print $_POST['sulleyaddress']; ?> </p>
<p class="question"> What is your favorite color? <?php print $_POST['question1']; ?> </p>
<p class="question"> Where were you born? <?php print $_POST['question2']; ?> </p>
<p class="question"> What is your favorite food? <?php print $_POST['question3']; ?> </p>
<p class="question"> What is your favorite movie? <?php print $_POST['question4']; ?> </p>
<p class="question"> What is your favorite book? <?php print $_POST['question5']; ?> </p>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input type="submit" name="edit" value="Edit" />
</form>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input type="submit" name="confirm" value="Finish" />
</form>
</div>
</div>
This is the problem area. This last step of the if else statement will not work properly. I'm not sure why. Any help is needed. Thanks.
<?php } elseif (isset($_POST['confirm'])) {
?>
<!--=============================================Form Confirmed--------------------------------------->
<div id="content-container">
<div id="content">
<p> Thank you, your data has been submitted</p>
</div>
</div>
<?php }
?>
</body>
</html>
You've got two form tags. One has the submit, one the hidden field.
You're not passing the variable therefore.
Try troubleshooting!
echo '<pre>';
print_r($_POST);
I would guess that it is because the forms are empty.
Try:
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input id='placeholder' name='placeholder' type='text' value='placeholder' hidden>
<input type="submit" name="confirm" value="Finish" />
</form>

How to add/change fields dynamicaly in form from if else condition?

Here i have numerous input fields in a form, which are working perfectly. And now, i want to add new input boxes and their labels according to property_type , Which is already exist on this page.
Now, Kindly Suggest me How can i add new fields in that form.
Here is my Form Code
<div class="dashboard_price_left">
<h3>
<?php
if ($this->lang->line('BasePrice') != '') {
echo stripslashes($this->lang->line('BasePrice'));
} else
echo "Base Price";
?>
</h3>
<p>
<?php
if ($this->lang->line('Atitleandsummary') != '') {
echo stripslashes($this->lang->line('Atitleandsummary'));
} else
echo "Set weekly or monthly price guests will see for your listing.";
?>
</p>
</div>
<?php
if ($listDetail->row()->home_type == 'Office') {
} else if ($listDetail->row()->home_type == 'House') {
}
?>
<form id="pricelist" name="pricelist" action="site/product/savePriceList" method="post">
<div class="dashboard_price_right">
<label><?php
if ($this->lang->line('Pernight') != '') {
echo stripslashes($this->lang->line('Pernight'));
} else
echo "Per night";
?>
</label>
<div class="amoutnt-container">
<?php if ($currentCurrency == '') { ?>
<span class="WebRupee"><?php echo $currencyDetail->row()->currency_symbols; ?></span>
<?php } else { ?>
<span class="WebRupee"><?php echo $currentCurrency; ?></span>
<?php } ?>
<input type="text" id="price" value="<?php
if ($listDetail->row()->price != '0.00') {
echo intval($listDetail->row()->price);
}
?>" class="per_amount_scroll" name="price" onkeypress="return onlyNumbersWithDot(event);" onchange="javascript:Detailview(this,<?php echo $listDetail->row()->id; ?>, 'price');" />
<input type="hidden" id="id" name="id" value="<?php echo $listDetail->row()->id; ?>" />
</div>
<div class="dashboard_currency">
<label><?php
if ($this->lang->line('Currency') != '') {
echo stripslashes($this->lang->line('Currency'));
} else
echo "Currency";
?>
</label>
<div class="select select-large select-block">
<select name="currency" id="currency" onchange="javascript:Detailview(this,<?php echo $listDetail->row()->id; ?>, 'currency');get_currency_symbol(this)" >
<!--<option value="">select</option>-->
<?php foreach ($currencyDetail->result() as $currency) { ?>
<option value="<?php echo $currency->currency_type; ?>" <?php if ($listDetail->row()->currency == $currency->currency_type) echo 'selected="selected"'; ?>><?php echo $currency->currency_type; ?></option>
<?php } ?>
</select>
</div>
</div>
</div>
</form>
Here is a pic of my Property prices form
Note: There are two types of property that are following:
1. Office
2. House
on the basis of these property, I want to add more fields in my form.
Please suggest me, Thanks in Advance :)
you can change it base on conditon and pass hidden field which indicates you office or house.
<?php
if ($listDetail->row()->home_type == 'Office')
{
<input type="hidden" name="home_type" value="Office" />
<input type="text" name="per_day" value="" />
<input type="text" name="half_day" value="" />
<input type="text" name="per_hour" value="" />
}
else if ($listDetail->row()->home_type == 'House')
{
<input type="hidden" name="home_type" value="House" />
<input type="text" name="per_night" value="" />
<input type="text" name="per_day" value="" />
<input type="text" name="per_hour" value="" />
}
?>

foreach inside of foreach

I have this code, which is very long, sorry.
<ul id="org" style="display:none">
<?php foreach ($note1 as $item1) { ?>
<li>
<?php echo $item1->Node_Id; ?>
<?php foreach ($noteLevel1 as $item2) { ?>
<p style="font-size:15px;padding:10px 5px 10px 0px"><?php echo $item2->LabelNote; ?></p>
<div class="SmallBox" id="<?php echo $item2->DetailNode_id; ?>" style="margin-bottom:10px;">
<input type="text" value="<?php if(empty($item2->Realisasi)) { echo ''; }else{ echo number_format($item2->Realisasi,0,",","."); } ?>" class="TextInput" />
<input type="text" value="<?php if(empty($item2->Target)) { echo ''; }else{ echo number_format($item2->Target,0,",","."); } ?>" class="TextInput" />
<input type="text" value="<?php if(!empty($item2->PercentRealisasi)) { echo $item2->PercentRealisasi.'%'; }else{ echo '0%'; } ?>" class="PercentInput" />
<img class="circles4" src='http://localhost/CST/public/img/green.png' onload="this.onload=null; this.src=GetStatusImage(<?php echo $item2->PercentRealisasi; ?>);" />
</div >
<?php } ?>
<div class="clearDiv"></div>
<?php foreach ($note2 as $item3) { ?>
<?php echo $item3->Node_Id.'T'.$item3->ParentNode; ?>
<ul>
<?php foreach ($noteLevel2 as $item4) { ?>
<li>
<p class="NodeLabel"><?php echo $item4->LabelNote; ?></p>
<div id="<?php echo $item4->DetailNode_id; ?>" class="SmallBox">
<center>
<input type="text" value="<?php if(empty($item4->Realisasi)) { echo ''; }else{ echo number_format($item4->Realisasi,0,",",".");} ?>" class="TextInput" readonly="true"/>
<input type="text" value="<?php if(empty($item4->Target)) { echo ''; }else{ echo number_format($item4->Target,0,",","."); } ?>" class="TextInput" readonly="true"/>
<input type="text" value="<?php if(!empty($item4->PercentRealisasi)) { echo $item4->PercentRealisasi.'%'; }else{ echo '0%'; } ?>" class="PercentInput" readonly="true"/>
<img class="circles" src='http://localhost/CST/public/img/green.png' onload="this.onload=null; this.src=GetStatusImage(<?php echo $item4->PercentRealisasi; ?>);" />
</center>
</div>
<?php foreach ($note3 as $item5) { ?>
<?php echo $item5->Node_Id.'T'.$item5->ParentNode; ?>
<ul>
<?php foreach ($noteLevel3 as $item6) { ?>
<li>
<p class="NodeLabel"><?php echo $item6->LabelNote; ?></p>
<div id="<?php echo $item6->DetailNode_id; ?>" class="SmallBox">
<center>
<input type="text" value="<?php if(empty($item6->Realisasi)) { echo ''; }else{ echo number_format($item6->Realisasi,0,",",".");} ?>" class="TextInput" readonly="true"/>
<input type="text" value="<?php if(empty($item6->Target)) { echo ''; }else{ echo number_format($item6->Target,0,",","."); } ?>" class="TextInput" readonly="true"/>
<input type="text" value="<?php if(!empty($item6->PercentRealisasi)) { echo $item6->PercentRealisasi.'%'; }else{ echo '0%'; } ?>" class="PercentInput" readonly="true"/>
<img class="circles" src='http://localhost/CST/public/img/green.png' onload="this.onload=null; this.src=GetStatusImage(<?php echo $item6->PercentRealisasi; ?>);" />
</center>
</div>
</li>
<?php } ?>
</ul>
<?php } ?>
</li>
<?php } ?>
</ul>
<?php } ?>
</li>
<?php } ?>
</ul>
You can see the table in this picture:
The result should be like this:
I want node_id to appear when node_id is equal with parent_node. But when I try to add code like this:
<?php foreach ($note3 as $item5) { ?>
**<?php if($item5->ParentNode == $item3->Node_Id){ ?>**
<?php echo $item5->Node_Id.'T'.$item5->ParentNode; ?>
<ul>
<?php foreach ($noteLevel3 as $item6) { ?>
<li>
<p class="NodeLabel"><?php echo $item6->LabelNote; ?></p>
<div id="<?php echo $item6->DetailNode_id; ?>" class="SmallBox">
<center>
<input type="text" value="<?php if(empty($item6->Realisasi)) { echo ''; }else{ echo number_format($item6->Realisasi,0,",",".");} ?>" class="TextInput" readonly="true"/>
<input type="text" value="<?php if(empty($item6->Target)) { echo ''; }else{ echo number_format($item6->Target,0,",","."); } ?>" class="TextInput" readonly="true"/>
<input type="text" value="<?php if(!empty($item6->PercentRealisasi)) { echo $item6->PercentRealisasi.'%'; }else{ echo '0%'; } ?>" class="PercentInput" readonly="true"/>
<img class="circles" src='http://localhost/CST/public/img/green.png' onload="this.onload=null; this.src=GetStatusImage(<?php echo $item6->PercentRealisasi; ?>);" />
</center>
</div>
</li>
<?php } ?>
</ul>
<?php } ?>
<?php } ?>
And the result should be like this:
It's like I just loop with the first index of the array. How can I fix it?

double serialize function checkbook in php

I have 3 checkbook with 3 option answer every checkbook. I'm saving every checkbook using serialize, but I can't save the data if the check book has 1 more answer.
<?php if( ! empty($questiontype)): ?>
<label>Answer Type</label><br>
<label>A</label>
<div class="form-group">
<?php foreach($questiontype as $key => $val): ?>
<label class="checkbox-inline" >
<input name="meta_answertype[][]" value="<?php echo $key; ?>" type="checkbox"<?php if($key == #$meta['answertype'][0][0]) echo 'checked'; ?> /> <?php echo $val; ?>
</label>
<?php endforeach; ?>
</div>
<label>B</label>
<div class="form-group">
<?php foreach($questiontype as $key => $val): ?>
<label class="checkbox-inline">
<input name="meta_answertype[][]" value="<?php echo $key; ?>" type="checkbox"<?php if($key == #$meta['answertype'][1][1]) echo 'checked'; ?> /> <?php echo $val; ?>
</label>
<?php endforeach; ?>
</div>
<label>C</label>
<div class="form-group">
<?php foreach($questiontype as $key => $val): ?>
<label class="checkbox-inline">
<input name="meta_answertype[][]" value="<?php echo $key; ?>" type="checkbox"<?php if($key == #$meta['answertype'][2][2]) echo 'checked'; ?> /> <?php echo $val; ?>
</label>
<?php endforeach; ?>
</div>
<?php endif; ?>

Selected radio button make field true or false

I have the following code:
<?php $radioSwitch = of_get_option('radio_switch');
if ($radioSwitch == "true") { ?>
<!-- radio switch -->
<div class="row switches clearfix">
<input type="radio" name="switch" id="switch1" value="<?php echo of_get_option('switch1'); ?>" /><label for="switch1" class="field"><?php echo of_get_option('switch1'); ?></label>
<input type="radio" name="switch" id="switch2" value="<?php echo of_get_option('switch2'); ?>" /><label for="switch2" class="field"><?php echo of_get_option('switch2'); ?></label>
</div>
<?php } ?>
................................................................................
<?php
$datePicker1 = of_get_option('datepicker1');
$datePicker2 = of_get_option('datepicker2');
if (($datePicker1 == "true") || ($datePicker2 == "true")) { ?>
<div class="row clearfix">
<?php if ($datePicker1 == "true") { ?>
<!-- datepicker 1 -->
<input type="text" id="dateFrom" name="<?php echo of_get_option('datepicker1_text'); ?>" value="<?php echo of_get_option('datepicker1_text'); ?>" tabindex="6" />
<label class="error" for="dateFrom" id="dateFrom_error">Selectați data.</label>
<?php } ?>
<?php if ($datePicker2 == "true") { ?>
<!-- datepicker 2 -->
<input type="textarea" id="dateTo" name="<?php echo of_get_option('datepicker2_text'); ?>" value="<?php echo of_get_option('datepicker2_text'); ?>" tabindex="7" />
<label class="error" for="dateTo" id="dateTo_error">Selectați data.</label>
<?php } ?>
</div>
<?php } ?>
If radio button "switch1" is selected, only "$datepicker1" must be true and "$datepicker2" must be false, and if radio button "switch2" is selected, both "$datepicker1" and "$datepicker2" must be true. Anyone could help me?
PHP is a server-side language which is parsed on the server. You cannot modify variables of PHP on the browser.
Try submitting the radio button options as a form into a PHP page.

Categories