Jump to content

Adding a value to a php input form field.


colleyboy

Recommended Posts

Hiya pplz.

 

I am trying to add: class="keyboardInput" to activate a javascript script to an input box.

 

This is the line im trying to add it to:

 

<td><?php echo form_input(array('name'=>'quantity','value'=>$item['quantity'],'size'=>'2'));?></td>

 

I have tried:

 

<td><?php echo form_input(array('name'=>'quantity','value'=>$item['quantity'],'size'=>'2'));? class="keyboardInput"></td>

 

didn't work.

 

Any help would be great.

 

Ian

Link to comment
Share on other sites

Hiya.

 

The page does not error but the script I put in the header.php file:

 

Header.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>


<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<base href="<?php echo base_url();?>" />
<title><?php echo $this->config->item('company').' -- '.$this->lang->line('common_powered_by').' IRCPOS System' ?></title>
<link rel="stylesheet" rev="stylesheet" href="<?php echo base_url();?>css/phppos.css" />
<link rel="stylesheet" rev="stylesheet" href="<?php echo base_url();?>css/phppos_print.css"  media="print"/>

<script src="<?php echo base_url();?>js/jquery-1.2.6.min.js" type="text/javascript" language="javascript" charset="UTF-8"></script>
<script src="<?php echo base_url();?>js/jquery.color.js" type="text/javascript" language="javascript" charset="UTF-8"></script>
<script src="<?php echo base_url();?>js/jquery.metadata.js" type="text/javascript" language="javascript" charset="UTF-8"></script>
<script src="<?php echo base_url();?>js/jquery.form.js" type="text/javascript" language="javascript" charset="UTF-8"></script>
<script src="<?php echo base_url();?>js/jquery.tablesorter.min.js" type="text/javascript" language="javascript" charset="UTF-8"></script>
<script src="<?php echo base_url();?>js/jquery.ajax_queue.js" type="text/javascript" language="javascript" charset="UTF-8"></script>
<script src="<?php echo base_url();?>js/jquery.bgiframe.min.js" type="text/javascript" language="javascript" charset="UTF-8"></script>
<script src="<?php echo base_url();?>js/jquery.autocomplete.js" type="text/javascript" language="javascript" charset="UTF-8"></script>
<script src="<?php echo base_url();?>js/jquery.validate.min.js" type="text/javascript" language="javascript" charset="UTF-8"></script>
<script src="<?php echo base_url();?>js/thickbox.js" type="text/javascript" language="javascript" charset="UTF-8"></script>
<script src="<?php echo base_url();?>js/common.js" type="text/javascript" language="javascript" charset="UTF-8"></script>
<script src="<?php echo base_url();?>js/manage_tables.js" type="text/javascript" language="javascript" charset="UTF-8"></script>

<style type="text/css">
html {
    overflow: auto;
}
</style>

<script type="text/javascript" src="keyboard.js" charset="UTF-8"></script>
<link rel="stylesheet" type="text/css" href="keyboard.css">

</head>
<body BGCOLOR="#c3c3c3">

<font size="3" face="verdana">
<CENTER><u><?php echo $this->config->item('company'); ?></u></CENTER>
</font>		
<font size="1" face="verdana">
<CENTER><?php echo $this->lang->line('common_powered_by').' IRCPOS System'; ?></CENTER>
</font>



<div id="menubar">


<BR><BR>

<TABLE CELLPADDING="0" CELLSPACING="0" BORDER="0" WIDTH="80%">

<TR><TD><FONT SIZE="1" FACE="VERDANA" COLOR="BLACK">

			<a href="<?php echo site_url('home');?>">
			<img src="<?php echo base_url().'images/menubar/home.png';?>" border="0" alt="Menubar Image" /></a>


			<CENTER><a href="<?php echo site_url("home");?>"><?php echo $this->lang->line("module_home") ?></a></CENTER>

</TD><TD><FONT SIZE="1" FACE="VERDANA">

		<?php
		foreach($allowed_modules->result() as $module)
		{
			if($module->module_id == 'cost_price') continue;
		?>
			<a href="<?php echo site_url("$module->module_id");?>">
			<img src="<?php echo base_url().'images/menubar/'.$module->module_id.'.png';?>" border="0" alt="Menubar Image" /></a>

			<CENTER><a href="<?php echo site_url("$module->module_id");?>"><?php echo $this->lang->line("module_".$module->module_id) ?></a></CENTER><TD><TD><FONT SIZE="1" FACE="VERDANA">

		<?php
		}
		?>



</TD></TR></TABLE>

</div>

<font size="2" face="verdana">
<?php echo date('F d, Y') ?> - <B><?php echo $this->lang->line('common_welcome')." $user_info->first_name $user_info->last_name! | "; ?></B><?php echo anchor("home/logout",$this->lang->line("common_logout")); ?>



</font>

<div id="content_area_wrapper">
<div id="content_area">

<FONT FACE="VERDANA" SIZE="1">

 

The javascript is inserted (correctly I hope).

 

The other page register.php is where my sales register is.

 

The script SHOULD let me be able to open a mini keyboard for each input box.

 

Register.php:

 

<?php $this->load->view("partial/header"); ?>
<div id="page_title" style="margin-bottom:8px;"><?php echo $this->lang->line('sales_register'); ?></div>
<?php
if(isset($error))
{
echo "<div class='error_message'>".$error."</div>";
}
?>
<div id="register_wrapper">
<?php echo form_open("sales/change_mode",array('id'=>'mode_form')); ?>
<span><?php echo $this->lang->line('sales_mode') ?></span>
<?php echo form_dropdown('mode',$modes,$mode,'onchange="$(\'#mode_form\').submit();"'); ?>
</form>
<?php echo form_open("sales/add",array('id'=>'add_item_form')); ?>
<label id="item_label" for="item">

<?php
if($mode=='sale')
{
echo $this->lang->line('sales_find_or_scan_item');
}
else
{
echo $this->lang->line('sales_find_or_scan_item_or_receipt');
}
?>
</label>
<?php echo form_input(array('name'=>'item','id'=>'item','size'=>'40'));?>
<div id="new_item_button_register" >
	<?php echo anchor("items/view/-1/width:700",
	"<div class='small_button'><span>".$this->lang->line('sales_new_item')."</span></div>",
	array('class'=>'thickbox none','title'=>$this->lang->line('sales_new_item')));
	?>
</div>

</form>
<table id="register">
<thead>
<tr>
<th style="width:7%;"><?php echo $this->lang->line('common_delete'); ?></th>
<th style="width:6%;"><?php echo ucfirst($this->lang->line('common_edit'))?></th>
<th style="width:22%;"><?php echo $this->lang->line('sales_item_name'); ?></th>
<th style="width:3%;"><?php echo $this->lang->line('sales_points'); ?></th>
<th style="width:3%;"><?php echo $this->lang->line('sales_points_required'); ?></th>
<th style="width:4%;"><?php echo $this->lang->line('sales_reward_discount'); ?></th>
<th style="width:6%;"><?php echo $this->lang->line('sales_price'); ?></th>
<th style="width:8%;"><?php echo $this->lang->line('sales_quantity'); ?></th>
<th style="width:8%;"><?php echo $this->lang->line('sales_discount'); ?></th>
<th style="width:8%;"><?php echo $this->lang->line('sales_total'); ?></th>
<th style="width:20%;"><?php echo $this->lang->line('sales_comment'); ?></th>
<th style="width:6%;"><?php echo $this->lang->line('sales_edit'); ?></th>
</tr>
</thead>
<tbody id="cart_contents">
<?php
if(count($cart)==0)
{
?>
<tr><td colspan='12'>
<div class='warning_message' style='padding:7px;'><?php echo $this->lang->line('sales_no_items_in_cart'); ?></div>
</tr></tr>
<?php
}
else
{
foreach($cart as $item_id=>$item)
{
	echo form_open("sales/edit_item/$item_id");
?>
	<tr>
	<td><?php echo anchor("sales/delete_item/$item_id",'['.$this->lang->line('common_delete').']');?></td>
	<td><?php echo anchor("items/view/$item_id/width:680",'['.$this->lang->line('common_edit').']',array('class'=>'thickbox none'));?></td>
	<td><?php echo $item['name']; ?></td>
	<td><?php echo $item['points']; ?></td>
	<td><?php echo $item['points_required']; ?></td>
	<td><?php echo to_currency($item['reward_discount']); ?></td>
	<?php if ($items_module_allowed)
	{
	?>
		<td><?php echo form_input(array('name'=>'price','value'=>$item['price'],'size'=>'4'));?></td>
	<?php
	}
	else
	{
	?>
		<td><?php echo $item['price']; ?></td>
		<?php echo form_hidden('price',$item['price']); ?>
	<?php
	}
	?>
	<td><?php echo form_input(array('name'=>'quantity','value'=>$item['quantity'],'size'=>'2','class'=>'keyboardInput'));?></td>
	<td><?php echo form_input(array('name'=>'discount','value'=>$item['discount'],'size'=>'3','class'=>'keyboardInput'));?></td>
	<td><?php echo to_currency($item['price']*$item['quantity']-$item['price']*$item['quantity']*$item['discount']/100); ?></td>
	<td><?php echo form_input(array('name'=>'item_comment','value'=>$item['item_comment'],'size'=>'10','class'=>'keyboardInput'));?></td>
	<td><?php echo form_submit("edit_item", $this->lang->line('sales_edit_item'));?></td>
	</tr>
	</form>
<?php
}
}
?>
</tbody>
</table>
</div>
<div id="overall_sale">

<?php
if(isset($customer))
{
	echo $this->lang->line("sales_customer").': '.$customer. '<br />';

	echo $enable_discount? anchor("sales/disable_discount",'['.$this->lang->line('sales_disable_discount').']<br />'):anchor("sales/enable_discount",'['.$this->lang->line('sales_enable_discount').']<br />');

	echo anchor("sales/delete_customer",'['.$this->lang->line('common_delete').' '.$this->lang->line('customers_customer').']');
}
else
{
	echo form_open("sales/select_customer",array('id'=>'select_customer_form')); ?>
	<label id="customer_label" for="customer"><?php echo $this->lang->line('sales_select_customer'); ?></label>
	<?php echo form_input(array('name'=>'customer','id'=>'customer','size'=>'30','value'=>$this->lang->line('sales_start_typing_customer_name')));?>
	</form>
	<div style="margin-top:5px;text-align:center;">
	<h3 style="margin: 5px 0 5px 0"><?php echo $this->lang->line('common_or'); ?></h3>
	<?php echo anchor("customers/view/-1/width:580",
	"<div class='small_button' style='margin:0 auto;'><span>".$this->lang->line('sales_new_customer')."</span></div>",
	array('class'=>'thickbox none','title'=>$this->lang->line('sales_new_customer')));
	?>
	</div>
	<div class="clearfix"> </div>
	<?php
}
?>

<div id='sale_details'>
	<div class="float_left" style="width:55%;"><?php echo $this->lang->line('sales_sub_total'); ?>:</div>
	<div class="float_left" style="width:45%;font-weight:bold;"><?php echo to_currency($subtotal); ?></div>

	<?php foreach($taxes as $name=>$value) { ?>
	<div class="float_left" style='width:55%;'><?php echo $name; ?>:</div>
	<div class="float_left" style="width:45%;font-weight:bold;"><?php echo to_currency($value); ?></div>
	<?php }; ?>

	<?php if($reward_discount > 0) { ?>
	<div class="float_left" style='width:55%;'><?php echo $this->lang->line('sales_reward_discount'); ?>:</div>
	<div class="float_left" style="width:45%;font-weight:bold;"><?php echo to_currency($reward_discount); ?></div>
	<?php } ?>

	<div class="float_left" style='width:55%;'><?php echo $this->lang->line('sales_total'); ?>:</div>
	<div class="float_left" style="width:45%;font-weight:bold;"><?php echo to_currency($total); ?></div>

	<div class="float_left" style='width:55%;'><?php echo $this->lang->line('sales_total_points'); ?>:</div>
	<div class="float_left" style="width:45%;font-weight:bold;"><?php echo ($totalpoints); ?></div>


</div>
<?php
if(count($cart) > 0)
{
?>
<div id="finish_sale">
	<?php echo form_open("sales/complete",array('id'=>'finish_sale_form')); ?>
	<br>
	<label id="comment_label" for="comment"><?php echo $this->lang->line('common_comments'); ?>:</label>
	<?php echo form_textarea(array('name'=>'comment','value'=>'','rows'=>'4','cols'=>'23'));?>
	<br><br>
	<table width="100%"><tr><td>
	<?php
		echo $this->lang->line('sales_payment').':   ';?>
	</td><td>
	<?php
	    echo form_dropdown('payment_type',$payment_options);?>
        </td>
        </tr>
        
        <tr>
        <td valign="top">
        <?php echo $this->lang->line('sales_amount_tendered').':   ';?>
	</td>
	<td>
		<div class="amount_tendered">
		<?php echo form_input(array('name'=>'amount_tendered','value'=>'','size'=>'10')); ?>
		</div>
		<div class="amount_tendered_1" style="display:none">
		Cash:<br /><?php echo form_input(array('id'=>'amount_tendered','name'=>'amount_tendered','value'=>'','size'=>'10')); ?><br />
		Card:<br /><?php echo form_input(array('id'=>'amount_tendered_1','name'=>'amount_tendered_1','value'=>'','size'=>'10')); ?>
		</div>
        </td>
        </tr>
        
        </table>
        <br>
	<?php echo "<div class='small_button' id='finish_sale_button' style='float:right;margin-top:5px;'><span>".$this->lang->line('sales_complete_sale')."</span></div>";
	?>
	</div>

	</form>

    <?php echo form_open("sales/cancel_sale",array('id'=>'cancel_sale_form')); ?>
		    <div class='small_button' id='cancel_sale_button' style='float:left;margin-top:5px;'>
				<span>Cancel Sale</span>
			</div>
        </form>
</div>
<?php
}
?>
</div>
<div class="clearfix" style="margin-bottom:30px;"> </div>


<?php $this->load->view("partial/footer"); ?>

<script type="text/javascript" language="javascript">
var total = <?php echo $total?>;
$(document).ready(function()
{
    $("#item").autocomplete('<?php echo site_url("sales/item_search"); ?>',
    {
    	minChars:0,
    	max:100,
       	delay:10,
       	selectFirst: false,
    	formatItem: function(row) {
		return row[1];
		console.log(row[1]);
	}
    });

$("[name='payment_type']").change(function() {
	if($(this).val() != 'Cash-Credit/Debit')
	{
		$(".amount_tendered").css('display','block');
		$(".amount_tendered_1").css('display','none');
	}
	else
	{
		$(".amount_tendered").css('display','none');
		$(".amount_tendered_1").css('display','block');
	}
});

    $("#item").result(function(event, data, formatted)
    {
	$("#add_item_form").submit();
    });

$('#item').focus();

$('#item').blur(function()
    {
    	$(this).attr('value',"<?php echo $this->lang->line('sales_start_typing_item_name'); ?>");
    });

$('#item,#customer').click(function()
    {
    	$(this).attr('value','');
    });

    $("#customer").autocomplete('<?php echo site_url("sales/customer_search"); ?>',
    {
    	minChars:0,
    	delay:10,
    	max:100,
    	formatItem: function(row) {
		return row[1];
	}
    });

    $("#customer").result(function(event, data, formatted)
    {
	$("#select_customer_form").submit();
    });

    $('#customer').blur(function()
    {
    	$(this).attr('value',"<?php echo $this->lang->line('sales_start_typing_customer_name'); ?>");
    });

    $("#finish_sale_button").click(function()
    {
	if($("[name='payment_type']").val() != 'Cash-Credit/Debit')
	{
		if( ! parseFloat($("[name='amount_tendered']").val()))
		{
			alert('Please enter valid amount!');
			return false;
		}
		else if(total > 0 && parseFloat($("[name='amount_tendered']").val()) < total)
		{
			alert('Insufficient Funds!');
			return false;
		}
	}
	else
	{
		if(( ! parseFloat($("#amount_tendered").val())) || ( ! parseFloat($("#amount_tendered_1").val())))
		{
			alert('Please enter valid amount!');
			return false;
		}
		else
		{
			var total_calculated = parseFloat($("#amount_tendered").val())+parseFloat($("#amount_tendered_1").val());
			if(total > 0 && total_calculated.toFixed(3) < total)
			{
				alert('Insufficient Funds!');
				return false;
			}
		}
	}

    	if (confirm('<?php echo $this->lang->line("sales_confirm_finish_sale"); ?>'))
    	{
    		$('#finish_sale_form').submit();
    	}
    });

    $("#cancel_sale_button").click(function()
    {
    	if (confirm('<?php echo $this->lang->line("sales_confirm_cancel_sale"); ?>'))
    	{
    		$('#cancel_sale_form').submit();
    	}
    });

<?php if(isset($alert_low_stack)) { ?>
alert('<?php echo $alert_low_stack?>');
<?php } ?>
});

function post_item_form_submit(response)
{
if(response.success)
{
	$("#item").attr("value",response.item_id);
	$("#add_item_form").submit();
}
}

function post_person_form_submit(response)
{
if(response.success)
{
	$("#customer").attr("value",response.person_id);
	$("#select_customer_form").submit();
}
}

</script>


Nothing is happening.  I cannot understand why either.

Help is needed and highly helpful as I am at a loose end.

Ian

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.