This question already has answers here:
"Notice: Undefined variable", "Notice: Undefined index", "Warning: Undefined array key", and "Notice: Undefined offset" using PHP
(29 answers)
Closed 7 years ago.
Hello i need your help or advice about one of my problem , so the thing is i have a multi language website (2 languages for now) and have a ad posting form witch starts on http://newproject.comli.com/step1.php and goes to a step2 and the problem starts if i change language on a step2 file its gives me an error like : enter image description here
you wont see those errors on a hosting but there will be no result ether .
so basically i am sending a ids from s step1 to a step2 , ids of user selection to display a category witch they select and later to insert to a database ware get those errors as well if i try to change a language after insert ( i mean i got them inserted into database and then if i change a language its gives me a tons of error it could be moved to a another page if you are trying to change language or just another way to avoid those errors ) the insertions page is ready but i didt create a table for it on my hosting so it wont work there
this is my pages code just to be more understandable what i am talking about and ware is the problem :
step1.php
<?php
include_once 'common.php';
?>
<!DOCTYPE html>
<html lang="<?php echo $lang['LANG']; ?>">
<head>
<title><?php echo $lang['PAGE_TITLE']; ?></title>
<meta charset="UTF-8">
<link rel="stylesheet" href="styles.css">
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<script src="js/ism-2.1.js"></script>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function() {
$(".level2 > li").hide();
$(".level1 > li").on("click", function() {
$(this).siblings().css("background-color", "transparent");
$(this).css("background-color", "#f1f1f1");
idx = $(this).index();
$(".level2 > li").hide();
$(".level2 > li").eq(idx).show();
});
$(".level3").hide();
$(".level2 > li > ul > li").on("click", function() {
$(".level2 > li > ul > li").css("background-color", "transparent");
$(this).css("background-color", "#f1f1f1");
$(".level3").hide();
var idx2 = $(this).index();
var idx1 = $(this).parent().parent().index();
$(".level3").show();
$("#catid").val("CAT" + (idx1+1) + "-" + (idx2+1));
});
});
</script>
</head>
<body>
<div class="advtop">
</div>
<div id="topbar2">
<div id="lang">
<ul>
<li>
<a href="?lang=lt" ><img src="image/Lithuania.png" ></a>
</li>
<li>
<img src="image/United Kingdom.png" >
</li>
</ul>
</div>
<div id="text">
<ul>
<li>
<?php
if(isset($_SESSION["username"]) && time() - $_SESSION["CREATED"] < 1800){
echo "Sveiki"; ?> <?php echo $_SESSION["username"]; ?><?php
}else {
?> <a href="post.php" ><?php echo $lang['LOGIN']; ?></a> <?php
}
?><span> |</span>
</li>
<li>
▽</span>
<ul class="dropdown">
<li><a class="first" href="#"><?php echo $lang['FAV']; ?> (0)</a></li>
<li><?php echo $lang['ADS']; ?></li>
<li><?php echo $lang['DETAILS']; ?></li>
<li>
<?php
if(isset($_SESSION["username"]) && time() - $_SESSION["CREATED"] < 1800){
?> <a href="logout.php" ><?php echo $lang['LOGOUT']; ?></a> <?php
}else {
?> <a href="post.php" ><?php echo $lang['REGISTER']; ?></a> <?php
} ?>
</li>
</ul>
</li>
</ul>
</div>
<div id="postadv">
<a href="<?php
if(isset($_SESSION["username"]) && time() - $_SESSION["CREATED"] < 1800){
echo "step1.php";
}else {
echo "post.php";
}
?>" ><?php echo $lang['POST']; ?></a>
</div>
</div>
<div id="logo2"><img src="image/logo.png"></div>
<div id="searchbox2">
<form class="form" action="search.php" method="get">
<input class="search-field" type="search" name="search" size="70" maxlength="50" placeholder="<?php echo $lang['SRC']; ?>" height="50">
<select class="categories" name="categories">
<option value="0" selected="selected"><?php echo $lang['ALLCAT']; ?></option>
<option value="1"><?php echo $lang['CAT1']; ?></option>
<option value="2"><?php echo $lang['CAT2']; ?></option>
<option value="3"><?php echo $lang['CAT3']; ?></option>
<option value="4"><?php echo $lang['CAT4']; ?></option>
<option value="5"><?php echo $lang['CAT5']; ?></option>
<option value="6"><?php echo $lang['CAT6']; ?></option>
<option value="7"><?php echo $lang['CAT7']; ?></option>
<option value="8"><?php echo $lang['CAT8']; ?></option>
<option value="9"><?php echo $lang['CAT9']; ?></option>
</select>
<input class="submit-button" type="submit" value="<?php echo $lang['SRCBTN']; ?>">
</form>
<a href="#" ><?php echo $lang['ADVSRC']; ?></a>
</div>
<div id="itemsCategLists">
<ul class="level1">
<li>
<span><?php echo $lang['CAT1']; ?></span>
<i class="fa fa-chevron-right"></i>
</li>
<li>
<span><?php echo $lang['CAT2']; ?></span>
<i class="fa fa-chevron-right"></i>
</li>
<li>
<span><?php echo $lang['CAT3']; ?></span>
<i class="fa fa-chevron-right"></i>
</li>
<li>
<span><?php echo $lang['CAT4']; ?></span>
<i class="fa fa-chevron-right"></i>
</li>
<li>
<span><?php echo $lang['CAT5']; ?></span>
<i class="fa fa-chevron-right"></i>
</li>
<li>
<span><?php echo $lang['CAT6']; ?></span>
<i class="fa fa-chevron-right"></i>
</li>
<li>
<span><?php echo $lang['CAT7']; ?></span>
<i class="fa fa-chevron-right"></i>
</li>
<li>
<span><?php echo $lang['CAT8']; ?></span>
<i class="fa fa-chevron-right"></i>
</li>
<li>
<span><?php echo $lang['CAT9']; ?></span>
<i class="fa fa-chevron-right"></i>
</li>
</ul>
<ul class="level2">
<li>
<ul class="level2list1">
<li><span><?php echo $lang['CAT1-1']; ?></span></li>
<li><span><?php echo $lang['CAT1-2']; ?></span></li>
<li><span><?php echo $lang['CAT1-3']; ?></span></li>
<li><span><?php echo $lang['CAT1-4']; ?> </span></li>
</ul>
</li>
<li>
<ul class="level2list1">
<li><span><?php echo $lang['CAT2-1']; ?></span></li>
<li><span><?php echo $lang['CAT2-2']; ?></span></li>
<li><span><?php echo $lang['CAT2-3']; ?></span></li>
<li><span><?php echo $lang['CAT2-4']; ?></span></li>
<li><span><?php echo $lang['CAT2-5']; ?></span></li>
<li><span><?php echo $lang['CAT2-6']; ?></span></li>
<li><span><?php echo $lang['CAT2-7']; ?></span></li>
<li><span><?php echo $lang['CAT2-8']; ?></span></li>
</ul>
</li>
<li>
<ul class="level2list1">
<li><span><?php echo $lang['CAT3-1']; ?></span></li>
<li><span><?php echo $lang['CAT3-2']; ?></span></li>
<li><span><?php echo $lang['CAT3-3']; ?></span></li>
<li><span><?php echo $lang['CAT3-4']; ?></span></li>
<li><span><?php echo $lang['CAT3-5']; ?></span></li>
<li><span><?php echo $lang['CAT3-6']; ?></span></li>
<li><span><?php echo $lang['CAT3-7']; ?></span></li>
<li><span><?php echo $lang['CAT3-8']; ?></span></li>
</ul>
</li>
<li>
<ul class="level2list1">
<li><span><?php echo $lang['CAT4-1']; ?></span></li>
<li><span><?php echo $lang['CAT4-2']; ?></span></li>
<li><span><?php echo $lang['CAT4-3']; ?></span></li>
<li><span><?php echo $lang['CAT4-4']; ?></span></li>
<li><span><?php echo $lang['CAT4-5']; ?></span></li>
<li><span><?php echo $lang['CAT4-6']; ?></span></li>
<li><span><?php echo $lang['CAT4-7']; ?></span></li>
</ul>
</li>
<li>
<ul class="level2list1">
<li><span><?php echo $lang['CAT5-1']; ?></span></li>
<li><span><?php echo $lang['CAT5-2']; ?></span></li>
<li><span><?php echo $lang['CAT5-3']; ?></span></li>
<li><span><?php echo $lang['CAT5-4']; ?></span></li>
<li><span><?php echo $lang['CAT5-5']; ?></span></li>
</ul>
</li>
<li>
<ul class="level2list1">
<li><span><?php echo $lang['CAT6-1']; ?></span></li>
<li><span><?php echo $lang['CAT6-2']; ?></span></li>
<li><span><?php echo $lang['CAT6-3']; ?></span></li>
<li><span><?php echo $lang['CAT6-4']; ?></span></li>
<li><span><?php echo $lang['CAT6-5']; ?></span></li>
<li><span><?php echo $lang['CAT6-6']; ?></span></li>
<li><span><?php echo $lang['CAT6-7']; ?></span></li>
</ul>
</li>
<li>
<ul class="level2list1">
<li><span><?php echo $lang['CAT7-1']; ?></span></li>
<li><span><?php echo $lang['CAT7-2']; ?></span></li>
<li><span><?php echo $lang['CAT7-3']; ?></span></li>
<li><span><?php echo $lang['CAT7-4']; ?></span></li>
<li><span><?php echo $lang['CAT7-5']; ?></span></li>
<li><span><?php echo $lang['CAT7-6']; ?></span></li>
<li><span><?php echo $lang['CAT7-7']; ?></span></li>
</ul>
</li>
<li>
<ul class="level2list1">
<li><span><?php echo $lang['CAT8-1']; ?></span></li>
<li><span><?php echo $lang['CAT8-2']; ?></span></li>
<li><span><?php echo $lang['CAT8-3']; ?></span></li>
<li><span><?php echo $lang['CAT8-4']; ?></span></li>
<li><span><?php echo $lang['CAT8-5']; ?></span></li>
</ul>
</li>
<li>
<ul class="level2list1">
<li><span><?php echo $lang['CAT9-1']; ?></span></li>
<li><span><?php echo $lang['CAT9-2']; ?></span></li>
<li><span><?php echo $lang['CAT9-3']; ?></span></li>
<li><span><?php echo $lang['CAT9-4']; ?></span></li>
</ul>
</li>
</ul>
<div class="level3">
<form id="step1" action="step2.php" method="post">
<input type="hidden" name="catid" id="catid">
<input class="submit-button" type="submit" name="submint" value="<?php echo $lang['NEXT']; ?>">
</form>
</div>
</div>
<div class="footer2">
<div class="copy">
<ul>
<li>
<a href="#" ><?php echo $lang['TERMS']; ?></a>
</li>
<li>
<a href="#" ><?php echo $lang['CONTACT']; ?></a>
</li>
</ul>
<span style="font-size: 13px; color: black"><?php echo $lang['COPY']; ?></span>
</div>
</div>
</body>
</html>
and step2.php
<?php
include_once 'common.php';
?>
<!DOCTYPE html>
<html lang="<?php echo $lang['LANG']; ?>">
<head>
<title><?php echo $lang['PAGE_TITLE']; ?></title>
<meta charset="UTF-8">
<link rel="stylesheet" href="styles.css">
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<script src="js/ism-2.1.js"></script>
</head>
<body>
<div class="advtop">
</div>
<div id="topbar2">
<div id="lang">
<ul>
<li>
<a href="?lang=lt" ><img src="image/Lithuania.png" ></a>
</li>
<li>
<img src="image/United Kingdom.png" >
</li>
</ul>
</div>
<div id="text">
<ul>
<li>
<?php
if(isset($_SESSION["username"]) && time() - $_SESSION["CREATED"] < 1800){
echo "Sveiki"; ?> <?php echo $_SESSION["username"]; ?><?php
}else {
?> <a href="post.php" ><?php echo $lang['LOGIN']; ?></a> <?php
}
?><span> |</span>
</li>
<li>
▽</span>
<ul class="dropdown">
<li><a class="first" href="#"><?php echo $lang['FAV']; ?> (0)</a></li>
<li><?php echo $lang['ADS']; ?></li>
<li><?php echo $lang['DETAILS']; ?></li>
<li>
<?php
if(isset($_SESSION["username"]) && time() - $_SESSION["CREATED"] < 1800){
?> <a href="logout.php" ><?php echo $lang['LOGOUT']; ?></a> <?php
}else {
?> <a href="post.php" ><?php echo $lang['REGISTER']; ?></a> <?php
} ?>
</li>
</ul>
</li>
</ul>
</div>
<div id="postadv">
<a href="<?php
if(isset($_SESSION["username"]) && time() - $_SESSION["CREATED"] < 1800){
echo "step1.php";
}else {
echo "post.php";
}
?>" ><?php echo $lang['POST']; ?></a>
</div>
</div>
<div id="logo2"><img src="image/logo.png"></div>
<div id="searchbox2">
<form class="form" action="search.php" method="get">
<input class="search-field" type="search" name="search" size="70" maxlength="50" placeholder="<?php echo $lang['SRC']; ?>" height="50">
<select class="categories" name="categories">
<option value="0" selected="selected"><?php echo $lang['ALLCAT']; ?></option>
<option value="1"><?php echo $lang['CAT1']; ?></option>
<option value="2"><?php echo $lang['CAT2']; ?></option>
<option value="3"><?php echo $lang['CAT3']; ?></option>
<option value="4"><?php echo $lang['CAT4']; ?></option>
<option value="5"><?php echo $lang['CAT5']; ?></option>
<option value="6"><?php echo $lang['CAT6']; ?></option>
<option value="7"><?php echo $lang['CAT7']; ?></option>
<option value="8"><?php echo $lang['CAT8']; ?></option>
<option value="9"><?php echo $lang['CAT9']; ?></option>
</select>
<input class="submit-button" type="submit" value="<?php echo $lang['SRCBTN']; ?>">
</form>
<a href="#" ><?php echo $lang['ADVSRC']; ?></a>
</div>
<div id="itemsCategLists2">
<div class="post2" >
<form class="formstyle" action="final.php" method="post" >
<div class="adtext">
<p><b><?php echo $lang['KAT']; ?>:</b>
</p>
<p><b><?php echo $lang['ACTION']; ?>*:</b>
</p>
<p><b><?php echo $lang['ADTITLE']; ?>*:</b><br>
</p>
<p><b><?php echo $lang['ADDETAILS']; ?>*:</b>
</p><br><br><Br>
<p><b><?php echo $lang['PRICE']; ?>*:</b>
</p>
<p><b><?php echo $lang['ADPHOTOS']; ?>:</b>
</p>
<p><b><?php echo $lang['UARE']; ?>*:</b>
</p>
<p><b><?php echo $lang['PHONE']; ?>*:</b>
</p>
<p><b><?php echo $lang['EMAIL']; ?>:</b>
</p>
<p><b><?php echo $lang['LOCATION']; ?>*:</b>
</p>
<p><b><?php echo $lang['NAME']; ?>*:</b>
</p>
<p><b><?php echo $lang['WEB']; ?>:</b>
</p>
</div>
<div class="entry">
<?php
$catid = $_POST['catid'];
$catid2 = substr($catid,0,4);
$cat1 = $lang[$catid2];
$cat2 = $lang[$catid];
echo "<font color='grey'>".$cat1." » ".$cat2."</font>";
?>
<br style="margin-bottom: 17px;">
<input type="hidden" name="catid" value="<?php echo $catid; ?>">
<input type="radio" name="action" value="1" required> <?php echo $lang['PORPOSE']; ?>
<input type="radio" name="action" value="2" required> <?php echo $lang['LOOKING']; ?><br style="margin-bottom: 15px;">
<input type="text" name="title" maxlength="80" pattern=".{10,}" title="At Least 10 symbols" min="10" style="width: 379px;" required><br style="margin-bottom: 15px;">
<textarea name="details" rows="10" cols="30" pattern=".{10,}" title="At Least 10 symbols" style="width: 379px; height: 75px;" maxlength="5500" required></textarea><br><br style="margin-bottom: 5px;">
<input type="text" name="price" maxlength="10" pattern="\d+(\.\d{2})?" title="Only numbers" required><br style="margin-bottom: 15px;">
<input type="file" multiple="true" name="image[]"><br style="margin-bottom: 15px;">
<input type="radio" name="ocp" value="1" required><?php echo $lang['PRV']; ?>
<input type="radio" name="ocp" value="2" required><?php echo $lang['BSN']; ?><br style="margin-bottom: 15px;">
<input type="text" name="phonenumber" pattern="^\s*\(?(020[7,8]{1}\)?[ ]?[1-9]{1}[0-9{2}[ ]?[0-9]{4})|(0[1-8]{1}[0-9]{3}\)?[ ]?[1-9]{1}[0-9]{2}[ ]?[0-9]{3})\s*$" title="Only UK Phone numbers ( 07*********) " required><br style="margin-bottom: 15px;">
<input type="email" name="email"><br style="margin-bottom: 15px;">
<input type="text" name="location" pattern=".[A-Za-z]{3,15}" title="Only letter (4-15 symbols)" required><br style="margin-bottom: 15px;">
<input type="text" name="name" pattern=".[A-Za-z]{3,15}" title="Only letter (4-15 symbols)" required><br style="margin-bottom: 15px;">
<input type="text" name="web" pattern="www\.\w+\.\w{2,3}|www\.\w+\.\w{2,3}\.\w{2}" title="Format :(www.website.com) "><br style="margin-bottom: 15px;">
<input class="submit-button" type="submit" name="submit" value="<?php echo $lang['POSTADV']; ?>">
</div>
</form>
</div>
</div>
<div class="footer2">
<div class="copy">
<ul>
<li>
<a href="#" ><?php echo $lang['TERMS']; ?></a>
</li>
<li>
<a href="#" ><?php echo $lang['CONTACT']; ?></a>
</li>
</ul>
<span style="font-size: 13px; color: black"><?php echo $lang['COPY']; ?></span>
</div>
</div>
</body>
</html>
okay so i think a little and find a solution for this not the best one but its seams no1 else can help me except my self so what i will try to do is check if a catid is isset and if not then just redirect back to a step1 so if some1 try to access the step2 page it will just redirect to step1 because catid will be not isset and same with language when i change language catid becomes not isset and it should redirect me to step1 page , tell me if i am thinking a right way and if not what i am doing wrong
Related
I have a page with two tabs and each tab can be showed If we clicked on a link inside a page.
Is there anyway to get to my tab and show tab's content ?
Here is my site url https://www.behealthy.asia/cp/
Here is the first tab https://www.behealthy.asia/cp/#regularuser
Here is the second tab https://www.behealthy.asia/cp/#company
and this is my code.
<div class="<?php echo esc_attr($getClasses); ?>">
<div class="tg-registerarea tg-haslayout">
<?php if (!empty($atts['title']))
{ ?>
<div class="tg-loginarea">
<div class="tg-bordertitle">
<h3><?php echo esc_attr($atts['title']); ?></h3>
</div>
</div>
<?php
} ?>
<fieldset>
<ul class="tg-tabnav" role="tablist">
<li role="presentation" class="active">
<a href="#regularuser" data-toggle="tab">
<span class="lnr lnr-user"></span>
<div class="tg-navcontent">
<h3><?php esc_html_e('Regular Single User', 'listingo_core'); ?></h3>
<span><?php esc_html_e('Register As Service Seeker', 'listingo_core'); ?></span>
</div>
</a>
</li>
<li role="presentation">
<a href="#company" data-toggle="tab">
<span class="lnr lnr-briefcase"></span>
<div class="tg-navcontent">
<h3><?php esc_html_e('Company / Professional', 'listingo_core'); ?></h3>
<span><?php esc_html_e('Register As Service Provider', 'listingo_core'); ?></span>
</div>
</a>
</li>
</ul>
<div class="tg-themetabcontent tab-content">
<div class="tab-pane active fade in" id="regularuser">
<form action="#" method="post" class="seeker-register do-registration-form">
<div class="form-group">
<div class="tg-registeras">
<span><?php esc_html_e('Already have an account? Please login', 'listingo_core'); ?></span>
</div>
</div>
<div class="form-group">
<input type="text" name="register[username]" class="form-control" placeholder="<?php esc_html_e('User Name, eg alex', 'listingo_core'); ?>">
</div>
<?php if (apply_filters('listingo_dev_manage_fields', 'true', 'user_nicename') === 'true')
{ ?>
<div class="form-group">
<input type="text" name="register[user_nicename]" class="form-control" placeholder="<?php esc_html_e('Nicename eg : alex', 'listingo_core'); ?>">
<?php do_action('listingo_get_tooltip', 'element', 'nicename'); ?>
</div>
<?php
} ?>
<?php if (apply_filters('listingo_dev_manage_fields', 'true', 'first_name') === 'true')
{ ?>
<div class="form-group">
<input type="text" name="register[first_name]" class="form-control" placeholder="<?php esc_html_e('First Name', 'listingo_core'); ?>">
</div>
<?php
} ?>
<?php if (apply_filters('listingo_dev_manage_fields', 'true', 'last_name') === 'true')
{ ?>
<div class="form-group">
<input type="text" name="register[last_name]" class="form-control" placeholder="<?php esc_html_e('Last Name', 'listingo_core'); ?>">
</div>
<?php
} ?>
<?php if (apply_filters('listingo_dev_manage_fields', 'true', 'gender') === 'true')
{ ?>
<div class="form-group">
<span class="tg-select">
<select name="register[gender]">
<option value=""><?php esc_html_e('Gender', 'listingo_core'); ?></option>
<option value="male"><?php esc_html_e('Male', 'listingo_core'); ?></option>
<option value="female"><?php esc_html_e('Female', 'listingo_core'); ?></option>
</select>
</span>
</div>
<?php
} ?>
<?php if (apply_filters('listingo_dev_manage_fields', 'true', 'phone') === 'true')
{ ?>
<div class="form-group">
<input type="text" name="register[phone]" class="form-control" placeholder="<?php esc_html_e('Phone', 'listingo_core'); ?>">
<?php do_action('listingo_get_tooltip', 'element', 'phone'); ?>
</div>
<?php
} ?>
<div class="form-group">
<input type="email" name="register[email]" class="form-control" placeholder="<?php esc_html_e('Email', 'listingo_core'); ?>">
</div>
<div class="form-group">
<input type="password" name="register[password]" class="form-control" placeholder="<?php esc_html_e('Password', 'listingo_core'); ?>">
</div>
<div class="form-group">
<input type="password" name="register[confirm_password]" class="form-control" placeholder="<?php esc_html_e('Retype Password', 'listingo_core'); ?>">
</div>
<?php do_action('listingo_registration_customer_extra_fields'); ?>
<div class="form-group term-group">
<?php
if (isset($captcha_settings) && $captcha_settings === 'enable')
{
?>
<div class="domain-captcha">
<div id="recaptcha_signup"></div>
</div>
<?php
} ?>
<div class="tg-checkbox">
<input name="terms" type="hidden" value="0" />
<input name="terms" type="checkbox" id="terms">
<label for="terms">
<?php if (!empty($terms_link))
{ ?>
<?php esc_html_e('I have read the', 'listingo_core'); ?> <a target="_blank" href="<?php echo esc_url($terms_link); ?>"><?php esc_html_e('Terms & Conditions', 'listingo_core'); ?></a> <?php esc_html_e('and accept them', 'listingo_core'); ?>
<?php
}
else
{ ?>
<?php
echo "ฉันยอมรับในเงื่อนไขและข้อกำหนดทุกประการ";
?>
<?php
} ?>
คลิกเพื่ออ่านเงื่อนไขและข้อกำหนด
</label>
<input type="hidden" name="register[account]" value="seeker">
<?php wp_nonce_field('register_seeker_request', 'register_seeker_request'); ?>
<button class="tg-btn do-regiter-me" type="submit"><?php esc_html_e('Register Now', 'listingo_core'); ?></button>
</div>
</div>
</form>
</div>
<div class="tab-pane fade in" id="company">
<form action="#" method="post" class="do-registration-form">
<div class="form-group">
<div class="tg-registeras">
<span><?php esc_html_e('Register As', 'listingo_core'); ?>:</span>
<div class="tg-radio">
<input type="radio" class="register_type" value="business" id="business" name="register[type]" checked>
<label for="business"><?php esc_html_e('Business', 'listingo_core'); ?></label>
</div>
<div class="tg-radio">
<input type="radio" class="register_type" value="professional" id="professional" name="register[type]">
<label for="professional"><?php esc_html_e('professional', 'listingo_core'); ?></label>
</div>
</div>
</div>
<div class="form-group">
<span class="tg-select">
<select name="register[category]" class="sp-category">
<option value=""><?php esc_html_e('Select Category', 'listingo_core'); ?></option>
<?php listingo_get_categories('', 'sp_categories'); ?>
</select>
</span>
</div>
Note that there is two tab, #regularuser and #company
I have two pages that need to submit to the database; a user registration page and a tire-input page. The user registration page works. The tire-input page does not. The tire page will show the alert inside the "submitClick()" but doesn't input anything into the database. If there is anymore information that you need, let me know. Thanks in advance.
I've tried working with the rules:
Current (letting the user-registration work, but not the tire-input)
{
"rules": {
"users": {
"$uid": {
".read": "$uid === auth.uid",
".write": "$uid === auth.uid"
}
}
}
}
Not letting anything work:
{
"rules": {
"users": {
"$uid": {
".read": "$uid === auth.uid",
".write": "$uid === auth.uid"
}
},
"Tires": {
".read": true,
".write": true
}
}
}
HTML code (tire):
<?php
require ($_SERVER['DOCUMENT_ROOT'] . '/Emily-Projects/variables.php');
?>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="../inc/styles/css.css">
</head>
<body>
<div class="container">
<div class="content" style="background-color: white;">
<div id="heading">
<h1>Add A Tire<h1>
</div>
<form>
<div id="1" class="form-sections">
<div class="input-div">
<label for="width" class="label">Width</label>
<select name="width" id="width" type="select" class="input">
<option value="">---</option>
<?php foreach ($tireWidths as $width) {?>
<option value="<?php echo $width;?>"><?php echo $width;?></option>
<?php } ?>
</select></div>
<div class="easy-div">
<div>
<?php foreach ($width100s as $width){ ?>
<z data-role="button" data-val="<?php echo $width;?>" class="width-sm"><?php echo $width?></z>
<?php } ?>
</div>
<div>
<?php foreach ($width200s as $width){ ?>
<z data-role="button" data-val="<?php echo $width;?>" class="width-sm"><?php echo $width?></z>
<?php } ?>
</div>
<div>
<?php foreach ($width300s as $width){ ?>
<z data-role="button" data-val="<?php echo $width;?>" class="width-sm"><?php echo $width?></z>
<?php } ?>
</div>
</div>
</div> <!-- closing div#1-->
<div id="2" class="form-sections">
<div class="input-div">
<label for="aspect" class="label">Aspect Ratio</label>
<select class="input" name="aspect" id="aspect">
<option value="">---</option>
<?php foreach ($aspects as $aspect) {?>
<option value="<?php echo $aspect;?>"><?php echo $aspect;?></option>
<?php }?>
</select>
</div>
<div class="easy-div">
<div>
<?php foreach ($aspectsTop as $a){ ?>
<z data-role="button" data-val="<?php echo $a;?>" class="aspectVal"><?php echo $a;?></z>
<?php } ?>
</div>
<div>
<?php foreach ($aspectsBottom as $a){ ?>
<z data-role="button" data-val="<?php echo $a;?>" class="aspectVal"><?php echo $a;?></z>
<?php } ?>
</div>
</div>
</div> <!-- closing div#2-->
<div id="3" class="form-sections">
<div class="input-div">
<label class="label" for="rim">Rim Diameter</label>
<select id="rim" name="rim" class="input">
<option value="">---</option>
<?php foreach ($rimDiameter as $rim){ ?>
<option value="<?php echo $rim;?>"><?php echo $rim;?></option>
<?php } ?>
</select>
</div>
<div class="easy-div">
<div>
<?php foreach ($rimDiaTop as $r) { ?>
<z data-role="button" data-val="<?php echo $r;?>" class="rimVal"><?php echo $r;?></z>
<?php }?>
</div>
<div>
<?php foreach ($rimDiaBottom as $r) { ?>
<z data-role="button" data-val="<?php echo $r;?>" class="rimVal"><?php echo $r;?></z>
<?php }?>
</div>
</div>
</div> <!-- closing div#3-->
<div id="4" class="form-sections">
<div class="input-div">
<label class="label" for="manufacturer">Manufacturer</label>
<select class="input" name="manufacturer" id="manufacturer">
<option value="">---</option>
<?php foreach ($manufacturers as $m) { ?>
<option value="<?php echo $m;?>"><?php echo $m;?></option>
<?php } ?>
</select>
</div>
<div class="easy-div">
<div id="manu-group-one">
<?php foreach ($manufacturersOne as $r) { ?>
<z data-role="button" data-val="<?php echo $r;?>" class="manVal"><?php echo $r;?></z>
<?php }?>
</div>
<div id="manu-group-two">
<?php foreach ($manufacturersTwo as $r) { ?>
<z data-role="button" data-val="<?php echo $r;?>" class="manVal"><?php echo $r;?></z>
<?php }?>
</div>
<div id="manu-group-three">
<?php foreach ($manufacturersThree as $r) { ?>
<z data-role="button" data-val="<?php echo $r;?>" class="manVal"><?php echo $r;?></z>
<?php }?>
</div>
<div id="manu-group-four">
<?php foreach ($manufacturersFour as $r) { ?>
<z data-role="button" data-val="<?php echo $r;?>" class="manVal"><?php echo $r;?></z>
<?php }?>
</div>
<div id="manu-group-five">
<?php foreach ($manufacturersFive as $r) { ?>
<z data-role="button" data-val="<?php echo $r;?>" class="manVal"><?php echo $r;?></z>
<?php }?>
</div>
<div id="manu-group-six">
<?php foreach ($manufacturersSix as $r) { ?>
<z data-role="button" data-val="<?php echo $r;?>" class="manVal"><?php echo $r;?></z>
<?php }?>
</div>
</div>
</div> <!-- closing div#4-->
<div id="5" class="form-sections">
<div id="5a" class="inner-B"><div class="input-div"><label class="label" for="model">Model</label>
<select id="model" name="model" class="input">
<option value="">---</option>
<option value="test">Test</option>
</select>
</div>
<div class="easy-div">EASY BUTTONS</div>
</div><!--closing A -->
<div id="5B" class="inner-A"><label class="label" for="weight">Shipping Weight</label><input type="text" name="weight" id="weight" class="input"></div><!--closing B -->
</div> <!-- closing div#5-->
<div id="6" class="form-sections">
<div id="6A" class="inner-C">
<div class="input-div">
<label class="label" for="trim">Trim</label>
<select name="trim" id="trim" class="input" >
<option value="">---</option>
<option value="test">Test</option>
</select>
</div>
<div class="easy-div">EASY BUTTONS</div>
</div><!--closing A -->
<div id="6B" class="inner-D">
<label class="label" for="cost">Tire Cost</label>
<input name="cost" id="cost" class="input">
</div><!--closing B -->
<div id="6C" class="inner-E">PICTURES</div><!--closing C -->
</div> <!-- closing div#6-->
<div id="7" class="form-sections">
<div id="7A" class="inner-D">
<div class="label">Run Flat?</div>
<div class="input"><input type="radio" name="runflat" value="yes"> Yes <input type="radio" name="runflat" value="no"> No </div>
</div><!--closing A -->
<div id="7B" class="inner-F">
<div class="label">Tread Depth</div>
<div class="input">
<input type="text" name="tread" id="tread" ><br><br>
<?php for($i=1; $i<11; $i++){ ?>
<z data-role="button" > <?php echo $i;?></z>
<?php } ?>
<?php for($i=11; $i<21; $i++){ ?>
<z data-role="button" > <?php echo $i;?></z>
<?php } ?> <z data-role="button" >.25 </z>
<z data-role="button" >.5</z>
<z data-role="button" >.75</z>
</div>
</div><!--closing B -->
<div id="7C" class="inner-F"><div class="label">DOT Date</div><div class="input">INPUT</div></div><!--closing C -->
<div id="7D" class="inner-F"><label class="label" for="patches">Number of Patches</label>
<div class="input"><?php for($i=0;$i<5;$i++){?>
<z data-role="button" ><?php echo $i;?></z>
<?php
}?></div></div> <!--closing D-->
</div> <!-- closing div#7-->
<div id="8" class="form-sections">
<div id="8A" class="inner-G"><div class="label">Retail Price</div>
<input type="text" id="retailPrice" name="retailPrice" class="input">
</div>
<div id="8B" class="inner-G"><div class="label">C.U.T. Share</div><div class="input">- $4.99 </div></div>
<div id="8C" class="inner-G"><div class="label">C.C. Fee</div><div class="input"><?php echo $ccfee;?></div></div>
<div id="8D" class="inner-G">Not Applicable</div>
<div id="8E" class="inner-G"><div class="label">Shipping Est.</div><div class="input"><?php echo $shipEst;?></div></div>
<div id="8F" class="inner-G"><div class="label">My Pay Out</div><div class="input"><?php echo $payOutRetail;?></div></div>
<div id="8G" class="inner-G"><div class="label">Tire NOT listed on Cheapest Used Tires</div><div class="input">INPUT</div></div>
</div> <!-- closing div#8-->
<div id="9" class="form-sections">
<div id="9A" class="inner-G"><div class="label">Wholesale Price</div>
<input type="text" id="retailPrice" name="retailPrice" class="input"></div>
<div id="9B" class="inner-G"><div class="label">C.U.T. Share</div><div class="input">- $4.99</div></div>
<div id="9C" class="inner-G"><div class="label">C.C. Fee</div><div class="input"><?php echo $ccfee;?></div></div>
<div id="9D" class="inner-G"><div class="label">Buyer's Bucks</div><div class="input">- $3.00</div></div>
<div id="9E" class="inner-G"><div class="label">Shipping Est.</div><div class="input"><?php echo $shipEst;?></div></div>
<div id="9F" class="inner-G"><div class="label">My Pay Out</div><div class="input"><?php echo $payOutWS;?></div></div>
<div id="9G" class="inner-G"><div class="label">Wholesale ONLY</div><div class="input">INPUT</div></div>
</div><!--closing div#9-->
<input type="submit" id="submit" onclick="submitClick()"value="Add This Tire">
</form>
</div>
</div> <!-- closing container -->
<script src="https://www.gstatic.com/firebasejs/4.6.2/firebase.js"></script>
<script src="/Emily-Projects/new-add-a-tire.js"></script>
</body>
</html>
Tire JS:
//File: new-add-a-tire.js
// Initialize Firebase
var config = {
apiKey: "AIzaSyCLpexd_9jOLjwcraume8RDXqag8mUSyMY",
authDomain: "funoto-a67ec.firebaseapp.com",
databaseURL: "https://funoto-a67ec.firebaseio.com",
projectId: "funoto-a67ec",
storageBucket: "funoto-a67ec.appspot.com",
messagingSenderId: "270438905275"
};
firebase.initializeApp(config);
//Add a Tire to Firbase
var width = document.getElementById("width");
var aspect = document.getElementById("aspect");
var rim = document.getElementById("rim");
var manufacturer = document.getElementById("manufacturer");
var submitBtn = document.getElementById("submit");
//Function: submitClick();
function submitClick(){
window.alert("Works");
var firebaseRef = firebase.database().ref();
firebaseRef.child("Tires").set("some value");
}
I am following the official doc try this
function submitClick(){
window.alert("Works");
var firebaseRef = firebase.database();
firebaseRef.ref("Tires").set({tire: "round"});
}
we have a marketplace site. each seller/vendor have their own account.
we are displaying list of sellers products , qty, sku...etc in their account.
http://prntscr.com/8vgul0
we are using this code to display those information :
<?php
$isPartner= Mage::getModel('marketplace/userprofile')->isPartner();
$helper= Mage::helper('marketplace');
if($isPartner==1){
?>
<script type="text/javascript">
if (typeof jQuery == 'undefined'){
document.write(unescape("%3Cscript src='//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js' type='text/javascript'%3E%3C/script%3E"));
}
</script>
<script src="//code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<link rel="stylesheet" href="//code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<div class="page-title">
<h1 style="float:left;"><?php echo $helper->__('My Product List') ?></h1>
</div>
<div class="wk_mp_design">
<div class="block block-account">
<div class="block-title">
<strong><span><h4><?php echo $helper->__('Product List') ?></h4></span></strong>
</div>
</div>
<div class="fieldset wk_mp_fieldset">
<div class="grid">
<div class="hor-scroll">
<form action="<?php echo Mage::helper('core/url')->getCurrentUrl();?>" method="post">
<table cellspacing="0" class="border wk_mp_list_table">
<thead>
<tr id="wk_mp_tr_heading">
<th><span><?php echo $helper->__('Product Name') ?></span></th>
<th><span><?php echo $helper->__('Date') ?></span></th>
<th><span><?php echo $helper->__('Product Status') ?></span></th>
<th><span> </span></th>
</tr>
</thead>
<tbody class="wk_mp_body">
<tr>
<td>
<input type="text" class="input-text" name="s" placeholder='<?php echo $helper->__('Search by product name') ?>' value="<?php echo $this->getRequest()->getParam('s')?>"/>
</td>
<td>
<span class="wk_mp_td_span">
<?php echo $helper->__('From: ') ?>
<input name="from_date" id="special_from_date" class="input-text" value="<?php echo $this->getRequest()->getParam('from_date')?>" />
</span>
<span class="wk_mp_td_span">
<?php echo $helper->__('To: ') ?>
<input name="to_date" id="special_to_date" class="input-text" value="<?php echo $this->getRequest()->getParam('to_date')?>" />
</span>
</td>
<td>
<select name="prostatus" class="input-text">
<option value=""><?php echo $helper->__('All') ?></option>
<option value="1" <?php if($this->getRequest()->getParam('prostatus') == 1) echo 'selected="selected"'?>>
<?php echo $helper->__('Approved') ?>
</option>
<option value="2" <?php if($this->getRequest()->getParam('prostatus') == 2) echo 'selected="selected"'?>>
<?php echo $helper->__('Unapproved') ?>
</option>
</select>
</td>
<td>
<button class="button" title="Save" type="submit">
<span><span><span><?php echo $helper->__('Submit') ?></span></span></span>
</button>
</td>
</tr>
</tbody>
</table>
</form>
<?php
if(count($this->getCollection())==0){ ?>
<div class="fieldset wk_mp_fieldset">
<div class="wk_emptymsg">
<?php echo $helper->__('No Product Available') ?>
</div>
</div>
<?php
} else{ ?>
<form action="<?php echo $this->getUrl('marketplace/marketplaceaccount/massdeletesellerpro') ?>" method="post" id="formmassdelete" name="formmassdelete">
<input type="hidden" name="form_key" value="<?php echo Mage::getSingleton('core/session')->getFormKey(); ?>" />
<button class="button" title="<?php echo $helper->__('Delete Products') ?>" type="submit" style="float: left;padding: 5px 5px 5px 0;" id="mass_delete_butn">
<span><span><?php echo $helper->__('Delete Products') ?></span></span>
</button>
<table cellspacing="0" class="border wk_mp_list_table wk_mp_list_container_table">
<thead>
<tr class="wk_content">
<th class="wk_check_first_td">
<span>
<input type="checkbox" name="mpselecctall" value="all" id="mpselecctall"/>
</span>
</th>
<th class="wk_first_td">
<span class="label name">
<?php echo $helper->__('Product')?>
</span>
</th>
<th class="wk_first_td">
<span class="label name">
<?php echo $helper->__('sku')?>
</span>
</th>
<th>
<span class="label pro_status">
<?php echo $helper->__('Status')?>
</span>
</th>
<!--
<th>
<span class="label qty">
<?php echo $helper->__('Qty. Confirmed')?>
</span>
</th>
<th>
<span class="label qty">
<?php echo $helper->__('Qty. Pending')?>
</span>
</th>
<th>
<span class="label qty">
<?php echo $helper->__('Qty. Sold')?>
</span>
</th>
-->
<th>
<span class="label">
<?php echo $helper->__('Qty')?>
</span>
</th>
<th>
<span class="label">
<?php echo $helper->__('Earn Amount')?>
</span>
</th>
<th>
<span class="label">
<?php echo $helper->__('Action')?>
</span>
</th>
</tr>
</thead>
<tbody>
<?php
$i = 0;
foreach($this->getCollection() as $products){
$i++;
$productMediaConfig = Mage::getModel('catalog/product_media_config');
$salesdetail=Mage::getModel('marketplace/saleslist')->getSalesdetail($products->getEntityId());
?>
<tr class="wk_row_view <?php echo $class = ($i == count($this->getCollection()))? 'wk_last_tr':''?>">
<td class="wk_check_first_td">
<span>
<input type="checkbox" name="product_mass_delete[]" class="mpcheckbox" value="<?php echo $products->getEntityId(); ?>"/>
</span>
</td>
<td class="wk_first_td">
<input type="hidden" class="hidden_id" value="<?php echo $products->getEntityId(); ?>" />
<div class="label name" title="<?php echo $products->getName(); ?>">
<div class="wk_pro_divide1">
<img src="<?php echo Mage::helper('catalog/image')->init($products,'thumbnail');?>" class="image" />
</div>
<div class="wk_pro_divide2">
<div style="width:100%;">
<a href="<?php echo $this->getUrl($products->getUrlPath())?>" target="blank">
<?php echo $products->getName();?>
</a>
</div>
<div style="width:100%;float:left;">
<?php echo Mage::helper('core')->currency($products->getPrice(), true, false);?>
</div>
</div>
</div>
</td>
<td>
<?php echo $sku = Mage::getModel('catalog/product')->load($products->getId())->getSku();?>
</td>
<?php
if($products->getStatus()==2) { ?>
<td>
<span class="label pro_status">
<?php echo $helper->__('Pending')?>
</span>
</td>
<td>
<span class="label qty">
<?php echo $helper->__('Pending')?>
</span>
</td>
<td>
<span class="label qty">
<?php echo $helper->__('Pending')?>
</span>
</td>
<td>
<span class="label qty">
<?php echo $helper->__('Pending')?>
</span>
</td>
<td>
<span class="label qty">
<?php echo $helper->__('Pending')?>
</span>
</td>
<?php }
else{
$id=$products->getId();
$productsolddetail=Mage::getModel('marketplace/saleslist')->getProductSalesDetailById($id);
$qtycom=0;
$com=0;
foreach($productsolddetail as $key){
$qtycom+=$key['magequantity'];
$com+=$key['actualparterprocost'];
} ?>
<td>
<span class="label pro_status">
<?php echo $helper->__('Approved')?>
</span>
</td>
<!-- edit qty -->
<td>
<?php echo (int)Mage::getModel('cataloginventory/stock_item')->loadByProduct($products)->getQty(); ?>
<span class="label wk_action">
<img src="<?php echo $this->getSkinUrl('marketplace/images/icon-edit.png'); ?>" data-type="<?php echo $products->getTypeId(); ?>" alt="<?php echo $helper->__('Edit')?>" title="<?php echo $helper->__('Edit')?>" class="mp_edit"/>
</span>
</td>
<!-- edit qty end -->
<!--
<td>
<span class="label qty">
<?php echo $salesdetail['quantitysoldconfirmed']; ?>
</span>
</td>
<td>
<span class="label qty">
<?php echo $salesdetail['quantitysoldpending']; ?>
</span>
</td>
<td>
<span class="label qty">
<?php echo $salesdetail['quantitysold']; ?>
</span>
</td>
-->
<td>
<span class="label price">
<?php echo Mage::helper('core')->currency($salesdetail['amountearned'], true, false); ?>
</span>
</td>
<?php
}?>
<td>
<span class="label wk_action">
<img src="<?php echo $this->getSkinUrl('marketplace/images/icon-edit.png'); ?>" data-type="<?php echo $products->getTypeId(); ?>" alt="<?php echo $helper->__('Edit')?>" title="<?php echo $helper->__('Edit')?>" class="mp_edit"/>
<img src="<?php echo $this->getSkinUrl('marketplace/images/icon-trash.png'); ?>" alt="<?php echo $helper->__('Delete')?>" title="<?php echo $helper->__('Delete')?>" class="mp_delete"/>
</span>
</td>
</tr>
<?php
}?>
</tbody>
</table>
</form>
<?php
}?>
</div>
</div>
<?php echo $this->getPagerHtml(); ?>
</div>
<div class="buttons-set">
<p class="back-link">
« <?php echo $helper->__('Back') ?>
</p>
</div>
</div>
<script>
var $wk_jq=jQuery.noConflict();
var newCustomerProductForm1 = new VarienForm('formmassdelete', true);
(function($wk_jq){
$wk_jq( "#special_from_date" ).datepicker({dateFormat: "yy-mm-dd"});
$wk_jq( "#special_to_date" ).datepicker({dateFormat: "yy-mm-dd"});
$wk_jq('body').delegate('.mp_edit','click',function(){
var id=$wk_jq(this).parents('.wk_row_view').find('.hidden_id').val();
var dicision=confirm('<?php echo $helper->__(" Are you sure you want to edit this product ? ")?>');
if(dicision==true){
var $type_id=$wk_jq(this).attr('data-type');
if($type_id=='simple')
window.location = "<?php echo $this->getUrl('marketplace/marketplaceaccount/editapprovedsimple/') ?>".concat("id/",id);
if($type_id=='downloadable')
window.location = "<?php echo $this->getUrl('marketplace/marketplaceaccount/editapproveddownloadable/') ?>".concat("id/",id);
if($type_id=='virtual')
window.location = "<?php echo $this->getUrl('marketplace/marketplaceaccount/editapprovedvirtual/') ?>".concat("id/",id);
if($type_id=='configurable')
window.location = "<?php echo $this->getUrl('marketplace/marketplaceaccount/editapprovedconfigurable/') ?>".concat("id/",id);
if($type_id=='grouped')
window.location = "<?php echo $this->getUrl('mpgroupproduct/index/editapprovedgrouped/') ?>".concat("id/",id);
<?php
//echo $this->getChildHtml('mpgrouped_productslist');
// echo $this->getChildHtml('mpbundle_productslist');
?>
if($type_id=='bundle')
window.location = "<?php echo $this->getUrl('mpbundleproduct/index/editbundle/') ?>".concat("id/",id);
}
});
$wk_jq('#mass_delete_butn').click(function(e){
var flag =0;
$wk_jq('.mpcheckbox').each(function(){
if (this.checked == true){
flag =1;
}
});
if (flag == 0){
alert("<?php echo $helper->__(' No Checkbox is checked ') ?>");
return false;
}
else{
var dicisionapp=confirm('<?php echo $helper->__(" Are you sure you want to delete these product ? ")?>');
if(dicisionapp==true){
$wk_jq('#form-customer-product-new').submit();
}else{
return false;
}
}
});
$wk_jq('#mpselecctall').click(function(event) {
if(this.checked) {
$wk_jq('.mpcheckbox').each(function() {
this.checked = true;
});
}else{
$wk_jq('.mpcheckbox').each(function() {
this.checked = false;
});
}
});
$wk_jq('.mp_delete').click(function(){
var id=$wk_jq(this).parents('.wk_row_view').find('.hidden_id').val();
var dicisionapp=confirm('<?php echo $helper->__(" Are you sure you want to delete this product ? ")?>');
if(dicisionapp==true)
window.location = "<?php echo $this->getUrl('marketplace/marketplaceaccount/delete/') ?>".concat("id/",id);
});
})($wk_jq);
</script>
<?php
}else{
echo "<h2 class='wk_new_msg'>".$helper->__("To BECOME SELLER PLEASE CONTACT TO ADMIN.")."</h2>";
}?>
we have a edit button next to "Qty", if we click on that edit button, its redirecting to another page and than seller edit the information and save it.
we are using following code to edit :
<span class="label wk_action">
<img src="<?php echo $this->getSkinUrl('marketplace/images/icon-edit.png'); ?>" data-type="<?php echo $products->getTypeId(); ?>" alt="<?php echo $helper->__('Edit')?>" title="<?php echo $helper->__('Edit')?>" class="mp_edit"/>
</span>
what we need is if we click on "edit" button, then it should display text field as like in the image and update and cancel button below.
Please refer below URL for admin grid:
http://www.atwix.com/magento/inline-editing-in-magento-backend-grids/
I'm not sure but this may help you. Try below for front-end :
Step 1 : Make onclick event on your edit image and call javascript function
eg : onclick="updateField(this, '. $product_id .'); return false";
Step 2 : Create javascript function which you have define in onclick of image.
<?php $url='Mage::getUrl('module_name/index/updateField/');' ?>
<script type="text/javascript">
function updateField(image, product_id)
{
new Ajax.Request('<?php echo $url ?>', {
method: 'post',
parameters: { id: fieldId, field: $(button).previous('input').getValue() }
});
}
</script>
Step: 3 Make function in your controller that you have define in java script ajax url.
public function updateFieldAction()
{
$fieldId = (int) $this->getRequest()->getParam('id');
$field = $this->getRequest()->getParam('field');
if ($fieldId) {
$model = Mage::getModel('modulename/model')->load($fieldId);
$model->setField($field);
$model->save();
}
}
Not able to pass the php variable into javascript function.
<p id = "demo"><?php echo $color; ?></p><br>
<?php while($rows = mysqli_fetch_array($result)) {
$color = $rows["clr"];
?>
<ul id="menu">
<li>
<h onclick="myFunction('<?php echo $color; ?>');">
<input type ="radio" name="radio" id ="php" value="<?php echo $color;?>">
<?php echo $color; ?>
<!--//<label for = "php" type:<?php echo $rpproduct_typ_color; ?>></label>-->
</h>
</li>
</ul>
<script type="text/javascript" >
function myFunction(a) {
document.getElementById('demo').innerHTML = a;
}
</script>
<?php } ?>
But this way it works fine:-
<ul id="menu">
<li>
<input type ="radio" name="radio" id ="php" value="<?php echo $color; ?>" onClick="document.getElementById('demo').innerHTML=this.value"> <?php echo $color; ?>
<!--//<label for = "php" type:<?php echo $color; ?> ></label>-->
</li>
</ul>
But i want to pass multiple values to the onClick function i want the firs tone to work
You have not closed the braces of the line:
<?php while($rows = mysqli_fetch_array($result))
{
The element does not exists, hence I made it a paragraph.
<p id="demo">EMPTY</p>
<br />
<ul id="menu">
<?php
$colours = array( '#FF0000', '#00FF00', '#0000FF' );
foreach( $colours AS $colour ) {
?><li>
<p onClick="changeColour('<?php echo $colour; ?>')">
<input type ="radio" name="radio" value="<?php echo $colour; ?>">
<?php echo $colour; ?>
</p>
</li>
<?PHP } ?>
</ul>
<script type="text/javascript" >
function changeColour( a ) {
document.getElementById('demo').innerHTML = a;
}
</script>
Tested and working
Did you mistake h for a headline h1..h6 maybe? Since there is no h tag in HTML, at least none that I know of. However, I'd suggest using a block-level element instead, such as div or p.
<li>
<p onclick="myFunction('<?php echo $color; ?>');">
<input type ="radio" name="radio" id ="php" value="<?php echo $color;?>">
<?php echo $color; ?>
</p>
</li>
This would give me an output such as this, which works fine in Opera:
<li>
<p onclick="myFunction('red');" style="background-color: red;">
<input type ="radio" name="radio" id ="php" value="red"> red
</p>
</li>
<li>
<p onclick="myFunction('blue');" style="background-color: blue;">
<input type ="radio" name="radio" id ="php" value="blue"> blue
</p>
</li>
In the Opencart filters I would like to change the Input Box Push to a click link;
Here is what I have at the minute;
<?php foreach($filter_groups as $filter_group){ ?>
<div>
<ul>
<li><span id="filter-group<?php echo $filter_group['filter_group_id']; ?>"><?php echo $filter_group['name']; ?></span>
<ul>
<?php foreach($filter_group['filter'] as $filter){ ?>
<?php if(in_array($filter['filter_id'], $filter_category)){ ?>
<li>
<input type="checkbox" value="<?php echo $filter['filter_id']; ?>" class="item" id="filter<?php echo $filter['filter_id']; ?>" checked="checked" />
<label for="filter<?php echo $filter['filter_id']; ?>"><?php echo $filter['name']; ?></label>
</li>
<?php } else { ?>
<li>
<input type="checkbox" value="<?php echo $filter['filter_id']; ?>" class="item" id="filter<?php echo $filter['filter_id']; ?>" />
<label for="filter<?php echo $filter['filter_id']; ?>"><?php echo $filter['name']; ?></label>
</li>
<?php } ?>
<?php } ?>
</ul>
</li>
</ul>
</div>
<?php } ?>
<script type="text/javascript">
$(document).ready(function() {
$('.item').live('change', function(){
filter = [];
$('input[type=\'checkbox\']:checked').each(function(element) {
filter.push(this.value);
});
location = '<?php echo $action; ?>&filter=' + filter.join(',');
});
});
//--></script>
I am guessing the HTML will change to something like this;
<?php foreach($filter_groups as $filter_group){ ?>
<div>
<ul>
<li><span id="filter-group<?php echo $filter_group['filter_group_id']; ?>"><?php echo $filter_group['name']; ?></span>
<ul>
<?php foreach($filter_group['filter'] as $filter){ ?>
<?php if(in_array($filter['filter_id'], $filter_category)){ ?>
<li class="selected">
<?php echo $filter['name']; ?>
</li>
<?php } else { ?>
<li>
<?php echo $filter['name']; ?>
</li>
<?php } ?>
<?php } ?>
</ul>
</li>
</ul>
</div>
<?php } ?>
I just have no idea how to approaching changing to so it submits an onclick location change that preserves the existing filters. Are you able to assist me?
Yes, that is correct, the new HTML should work. To make it simpler (without need of JavaScript) You may fill in the href attribute to this dynamic value:
<?php echo $filter['name']; ?>
(no need of id attribute). Now on click the URL is directly triggered changing the filter to new filter_id.
Keep in mind that the default approach let's the user to check more than one filter value however with Your approach only one filter value could be selected at a time.
It might be also usefull to display the currently selected filter only as a text node so that it is not clickable, e.g. like this:
<?php if(in_array($filter['filter_id'], $filter_category)){ ?>
<li class="selected">
<span><?php echo $filter['name']; ?></span>
</li>
<?php } else { ?>
<li>
<?php echo $filter['name']; ?>
</li>
<?php } ?>