Jump to content

Problem in function of enter key

- - - - -

  • Please log in to reply
6 replies to this topic

#1
newphpcoder

newphpcoder

    Programming Professional

  • Members
  • PipPipPipPipPipPip
  • 479 posts
Good day!

I got problem in my function on enter key.. I attached my files and code for better understanding of my problem..

Thank you in advance

Attached Files



#2
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,124 posts
  • Location:Vancouver, Eh! Cleverness: 200
Have you looked yourself where the problem may be?
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#3
newphpcoder

newphpcoder

    Programming Professional

  • Members
  • PipPipPipPipPipPip
  • 479 posts
I think the problem is i don't know how does the cursor go to the time in textbox not in save button after in lot /batch #

#4
newphpcoder

newphpcoder

    Programming Professional

  • Members
  • PipPipPipPipPipPip
  • 479 posts
Good day!

I encountered problem in pressing enter key. After I insert data in lot/batch# and I pressed Enter Key, instead of going to time in textbox it was go to save button which is wrong.

Here is my code:


<?php                     

                     if($rexist == 0)

                        {

                        $query = "SELECT t.operation_name, t.input_unit, t.output_unit FROM trace_operations t WHERE t.plt_typeno = '" . $_POST["plt_typeno"] . "'  AND t.operation_name IN ('01 Oper' , '02 Oper') ORDER BY t.operation_name";

                        $result = mysql_query($query);

                        if($result)

                            if($row = mysql_fetch_array($result))

                                {

                                    

                                echo "<p><center><b>OPERATOR AND MACHINE TRACEABILITY</center></b></p>";

                                echo "<table>";

                                echo "<tr>

                                <th class='myclass'>OPERATIONS</th>

                                <th class='myclass'>Time IN</th>

                                <th class='myclass'>Time OUT</th>

                                <th class='myclass'>INPUT <br/> QTY</th>

                                <th class='myclass'>UNIT</th>

                                <th class='myclass'>OUTPUT QTY</th>

                                <th class='myclass'>UNIT</th>

                                <th class='myclass'>ID #</th>

                                <th class='myclass'>MC #</th>

                                <th class='myclass'>VARIANCE Qty</th>

                                <th class='myclass'>VARIANCE PLT #</th>

                                <th class='myclass'>DATE</th>

                                <th class='myclass'>SHIFT</th></tr>";

                                echo "\n\t<tr>";

                                echo "\n\t\t<td width='800'>";

                                if ($last_operation_name != $row["operation_name"]) echo $row["operation_name"];

                                $last_operation_name = $row["operation_name"];

                                echo "<input type='hidden' width='400' name='opname[]' value='" . $row["operation_name"] . "' /></td>";   

                                echo "\n\t\t<td><input size='6' type='text' name='timein[]' id='timein" . $ctr . "' onkeypress='return handleEnter(event,\"timeout" . $ctr . "\");' /></td>";

                                echo "\n\t\t<td><input size='6' type='text' name='timeout[]' id='timeout" . $ctr . "' onkeypress='return handleEnter(event,\"inqty" . $ctr . "\");' /></td>";

                                echo "\n\t\t<td><input size='6' type='text' name='inqty[]' id='inqty" . $ctr . "' onkeypress='return handleEnter(event,\"outqty" . $ctr . "\");' /></td>";

                                echo "\n\t\t<td>" . $row["input_unit"];

                                echo "<input type='hidden' name='iun[]' value='" . $row["input_unit"] . "' /></td>";

                                echo "\n\t\t<td><input size='6' type='text' name='outqty[]' id='outqty" . $ctr . "' onkeypress='return handleEnter(event,\"idno" . $ctr . "\");' /></td>";

                                echo "\n\t\t<td>" . $row["output_unit"];

                                echo "<input type='hidden' name='oun[]' value='" . $row["output_unit"] . "'></td>";

                                echo "\n\t\t<td><input size='6' type='text' name='idno[]' id='idno" . $ctr . "' onkeypress='return handleEnter(event,\"mcno" . $ctr . "\");' /></td>";

                                echo "\n\t\t<td><input size='6' type='text' name='mcno[]' id='mcno" . $ctr . "' onkeypress='return handleEnter(event,\"varqty" . $ctr . "\");' /></td>";

                                echo "\n\t\t<td><input size='6' type='text' name='varqty[]' id='varqty" . $ctr . "' onkeypress='return handleEnter(event,\"varplt" . $ctr . "\");' /></td>";

                                echo "\n\t\t<td><input size='6' type='text' name='varplt[]' id='varplt" . $ctr . "' onkeypress='return handleEnter(event,\"dateshift" . $ctr . "\");' /></td>";

                                echo "\n\t\t<td><input size='6' type='text' name='dateshift[]' id='dateshift" . $ctr . "' onkeypress='return handleEnter(event,\"shift\");' /></td>";

                                echo "\n\t\t<td><input size='6' type='text' name='shift[]' id='shift" . $ctr . "' onkeypress='return handleEnter(event,\"saveform\");' /></td>";

                                echo "\n\t</tr>";

                                     }

                                echo "</table>";

            }

                echo "<p><input type='submit' value='Save' id='saveform' /></p>";

                echo "<input type='hidden' name='plt_typeno' value='" . $_POST["plt_typeno"] . "' />";

        }

        }

        }

        ?>

</form>

<form name="enumplt" action="yield_station1.php" method="post">

<input type="hidden" name="enum_plt" value="1" />

<input type="hidden" name="plt_typeno" />

</form>

</body>

</html>



#5
LuthfiHakim

LuthfiHakim

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 765 posts
^ It is the default action. Pressing enter key inside a form's input field (unless in multiple line field which makes a new line) will automatically calls the form's submit procedure (in your case it's like pressing the save button). You can change this behavior using JavaScript.

#6
newphpcoder

newphpcoder

    Programming Professional

  • Members
  • PipPipPipPipPipPip
  • 479 posts
How can I change it?

Thank you

#7
LuthfiHakim

LuthfiHakim

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 765 posts
My JavaScript is rusty, so I just googled and found this page that you might find interesting. :)

How to Convert Enter Key with Tab Key Functionality - JavaScript / Ajax / DHTML answers




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users