Jump to content

autofill problem


esandra

Recommended Posts

this script autofills the next textbox with a value of the last input + 1 onchange.

but what I want to do is to still let the user change the value of the second textbox?

 

the only value that the user could change it to is the value equal to the value of

the previous textbox or the prev value + 1 which is the autofill value

 

right now here is what it does to simplify the picture:

I type in 100

second textbox displays 101

when I try to change second textbox into 100,

it goes back to 101

 

function autocomplt(y){
var x=100   //100 row by 5 column form (orno, billnmbr,...)
for(var y = 1; y < x; y++)	{
	var orno="orno"+y
	var billnmbr="billnmbr"+y
	var payor="payor"+y
	var arrastre="arrastre"+y
	var wharfage="wharfage"+y

	var ornoval = document.getElementById(orno).value;

if(ornoval.length!=""){
	var nxtorno = (ornoval*1) + 1;
	var nxty = y+1

	orno="orno"+nxty
	billnmbr="billnmbr"+nxty
	payor="payor"+nxty
	arrastre="arrastre"+nxty
	wharfage="wharfage"+nxty

	document.getElementById(orno).readOnly = false;
	document.getElementById(billnmbr).readOnly = false;
	document.getElementById(payor).readOnly = false;
	document.getElementById(arrastre).readOnly = false;
	document.getElementById(wharfage).readOnly = false;

	document.getElementById(orno).value = nxtorno;
//above auto fills the next textbox orno+y
//but I want the user to be able to change the value

	break;
//I temporarily put break here to keep it from auto filling up to the 100th textbox that I have  
//because it's only supposed to fill one textbox after it
	}}
}

 

also this event happens onchange of the first orno+y

what do i do so that when I click on the second orno+y

the 3rd orno+y would change its value into 2nd_txtbox_value + 1?

so on and so forth...

 

thank you for your time

 

Here is the affected part of the form, just in case...

<?php
$num=100;
$nump=$num / 10;
$y=1;
for($j=1;$j<=$nump;$j++){
?>			
		<li>
            <p>
    <?php

    for($i=1;$i<=10;$i++){
	if(strlen($y)==1){
echo "0";
}

	if(strlen($y)==3){
echo $y."<font color=000000>....</font>";
	}
	else{
echo $y."      ";
		}
?>
         <input name="orno<?php echo $y;?>" id="orno<?php echo $y;?>" type="text" size="10" maxlength="6" onKeyPress="return isNumberKey(event)" value="<?php
if (isset($_POST['orno'])) {
	echo htmlspecialchars($_POST['orno'], ENT_QUOTES);
	}?>" onchange="autocomplt(<?php echo $y;?>);" >
        
         <input name="billnmbr<?php echo $y;?>" id="billnmbr<?php echo $y;?>" type="text" size="25" maxlength="17" value="<?php
if (isset($_POST['billnmbr'])) {
	echo htmlspecialchars($_POST['billnmbr'], ENT_QUOTES);
	}?>">
        
        <input name="payor<?php echo $y;?>" id="payor<?php echo $y;?>" type="text" size="40" maxlength="50" value="<?php
if (isset($_POST['payor'])) {
	echo htmlspecialchars($_POST['payor'], ENT_QUOTES);
	}?>">
        
        <input name="arrastre<?php echo $y;?>" id="arrastre<?php echo $y;?>" type="text" size="10" maxlength="8" onKeyPress="return isMoneyKey(event)" value="<?php
if (isset($_POST['arrastre'])) {
	echo htmlspecialchars($_POST['arrastre'], ENT_QUOTES);
	}?>" onchange="autototal(<?php echo $y; ?>);">
        
        <input name="wharfage<?php echo $y;?>" id="wharfage<?php echo $y;?>" type="text" size="10" maxlength="8" onKeyPress="return isMoneyKey(event)" value="<?php
if (isset($_POST['wharfage'])) {
	echo htmlspecialchars($_POST['wharfage'], ENT_QUOTES);
	}?>" onchange="autototal(<?php echo $y; ?>);">        
        
        <input name="total<?php echo $y;?>" id="total<?php echo $y;?>" type="text" size="10" onChange="return isMoneyKey(event)" value="<?php
if (isset($_POST['total'])) {
	echo htmlspecialchars($_POST['total'], ENT_QUOTES);
	}?>" disabled="disabled"><br />
        
        <?php $y++; 
echo "<input type=hidden name=y value=".$y.">";
	}?>
        </p>
		</li>
<?php $y=$y;
}//} ?>
	</ul>
</div>

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.