473,396 Members | 1,799 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

wrong variable in text field in firefox

Hello

Try to add some blank text field and refresh window
in IE it is ok but in firefox input hide_show works wrong , why ?
Somebody can help me ?

I'm not good in JS beacause I'm PHP coder

The completly code (mix of PHP and JS):

<?php
// -------------------------------------------------------------------------
----
if ($_POST['save']=="save"){
$account = $_POST['account'];
$hide_show = $_POST['hide_show'];

$_POST =(array_flip (array_values($_POST)));
$_POST =(array_flip ($_POST));
$y=0;
foreach ($_POST as $key => $val){
if (!empty($val) && $val!="" && strlen($val)==9){
$y++;
$arr['n'.($y)]=$val;
$set.= $val.",";
}
}
$arr['n'.($y+1)]=' ';
$_POST=$arr;
$_POST['hide_show']=$y+1;
$_POST['save'] = 'save';
echo ("<pre>");
print_r($_POST);
echo ("</pre>");
}
// -------------------------------------------------------------------------
----
if (!isset($_GET['account']) && !isset($_POST['account'])){
$account="numer testowy";
}
else {
if (isset($_POST['account'])){
$account=$_POST['account'];
}
else if (isset($_GET['account'])){
$account=$_GET['account'];
}
}
$form_num=20;
// -------------------------------------------------------------------------
----
?>
<script language="JavaScript" type="text/javascript">
function show(ida,idb){
id = 'numer' + ida;
if(document.getElementById(id)){
var ele = document.getElementById(id);
if(ele.style.display=="none"){
ele.style.display="block";
document.telacc.hide_show.value =
(document.telacc.hide_show.value - 0) + idb;
}
}
}
function hide(ida,idb){
if ((document.telacc.hide_show.value - 0) != 1 &&
(document.telacc.hide_show.value - 0) != 0 ){
id = 'numer' + ida;
var ele = document.getElementById(id);
ele.style.display="none";
document.telacc.hide_show.value = document.telacc.hide_show.value - idb;
}
}
function form_inp(name_field)
{
var Message = "";
var flag = true;
var name;
if (name_field!= "")
{
var wyraz = name_field;
var ilosc = wyraz.length;
wzor=/^[0-9]+$/;
if (ilosc!=9 || wzor.test(wyraz)==false){
name = "Pole musi zawierać 9 cyfr!\n"
flag = false
Message = Message + name
}
}
if (flag == false)
{
alert(Message)
}
}
function telacc_db()
{
var Message = "";
var flag = true;
var name;
if (document.telacc.n1.value != "")
{
var wyraz = document.telacc.n1.value;
var ilosc = wyraz.length;
wzor=/^[0-9]+$/;
if (ilosc!=9 || wzor.test(wyraz)==false){
name = "Pole nr. 1 musi zawierać 9 cyfr!\n"
flag = false
Message = Message + name
}
}
<?php
for ($x=1;$x<$form_num;$x++){
?>
if (document.telacc.n<?php echo ($x+1); ?>.value != "")
{
var wyraz = document.telacc.n<?php echo ($x+1); ?>.value;
var ilosc = wyraz.length;
wzor=/^[0-9]+$/;
if (ilosc!=9 || wzor.test(wyraz)==false){
name = "Pole nr. <?php echo ($x+1); ?> musi zawierać 9 cyfr!\n"
flag = false
Message = Message + name
}
}
<?php
}
?>
if (flag == true)
{
document.forms['telacc'].submit()
}
else
{
alert(Message)
}
}
</script>
<form action="test_form.php" name="telacc" method="POST">
<input type="hidden" name="save" value="save">
<input type="hidden" name="account" value="<?php echo $account;?>">
<?php
if (!isset($_POST['hide_show']))
{
echo "<input type=\"text\" name=\"hide_show\" value=1>";
}
else
{
echo "<input type=\"text\" name=\"hide_show\"
value=".$_POST['hide_show'].">";
}
?>
<?php
echo "<div id=\"numer1\" style=\"display:block;\">";
?>
<input type="text" size="9" maxlength="9" name="n1" value="<?php if
($_POST['n1']!=" "){echo $_POST['n1'];} ?>" onclick=show(2,1);
&nbsp;/&nbsp;<?php echo $account."&nbsp";?>

<a href=javascript:hide(1,1);
onClick=javascript:document.telacc.n1.value='';><i mg src="minus.gif"
border=0 align="absmiddle"></a>
</div>
<?php
for ($x=1;$x<$form_num;$x++){
echo "<div id=\"numer".($x+1)."\" style=\"display:";
if ($_POST['n'.($x+1)]!=""){
echo "block;\">";
}
else {
echo "none;\">";
}
echo "<input size=\"9\" maxlength=\"9\" type=\"text\" name=\"n".($x+1)."\"
value=\"";
if ($_POST['n'.($x+1)]!=' '){
echo $_POST['n'.($x+1)];
}
echo "\"onClick=show(".($x+2).",1); onkeyup=show(".($x+2).",1);
onFocus=form_inp(document.telacc.n".($x).".value); >&nbsp;/&nbsp;".$account."
&nbsp;";
echo "<a href=javascript:hide(".($x+1).",1);
onClick=javascript:document.telacc.n".($x+1).".val ue='';><img
src=\"minus.gif\" border=0 align=\"absmiddle\"></a>";
echo "</div>";
}
?>
<br>
<br>
<INPUT name="zapisz" onclick="telacc_db();" type="button" value="Zapisz">
</form>
<?php
// -------------------------------------------------------------------------
----
if ($_POST['save']=="save"){
if ($set==""){
echo "Kwerenda jest pusta!";
exit;
}
else {
echo $set."<br>".$account;
}
}
echo ("<pre>");
print_r($_POST);
echo ("</pre>");
// -------------------------------------------------------------------------
----
?>

Mar 22 '06 #1
3 2108
JaRudzik said the following on 3/22/2006 3:54 AM:
Hello

Try to add some blank text field and refresh window
in IE it is ok but in firefox input hide_show works wrong , why ?
Somebody can help me ?

I'm not good in JS beacause I'm PHP coder

The completly code (mix of PHP and JS):


When posting code, only post what gets sent to the browser. Or, post a
URL to a sample page. That way, people who may help you only have to
copy/paste the code or click a link to see it. Makes life a lot simpler.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Mar 22 '06 #2
http://www.studio-er.home.pl/test_form.php

for testing

BR.
Rafal
Mar 22 '06 #3
OK I resolved that
my own :)

<body onload=javascript:document.telacc.hide_show.value= '<?php echo
$_POST['hide_show']; ?>';>

BR
Rafał

Użytkownik "JaRudzik" <ja*********@poczta.onet.pl> napisał w wiadomo¶ci
news:dv**********@news.onet.pl...
http://www.studio-er.home.pl/test_form.php

for testing

BR.
Rafal

Mar 23 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Jack | last post by:
Hi, I got a asp form page where the POST ACTION = confirmation.asp page is used to save the values collected from text boxes from the form in a database. For example txtTotalOutlay field is being...
3
by: snowweb | last post by:
I'm creating my first web application in PHP/MySQL, however, when I go to view the database contents, the data has been stored in the wrong columns. I've gone through my insertion code with a fine...
4
by: _Raven | last post by:
Okay, I am playing with submitting forms with Ajax. I am trying to adapt this script to my forms: http://www.captain.at/howto-ajax-form-post-get.php I have included my code at the bottom of this...
4
by: somewildmonkey | last post by:
I'm running Firefox version 1.5.0.6 and when I load an html file containing the code shown below, although both the text field and the button are defined as 24 pixels in height, the text field is...
2
by: neeebs | last post by:
Hi, I'm not sure if this is a javascript problem per se, but here goes. I have an xsl document with a python function defined within a <script> block. Elsewhere in the xsl file, within a python...
3
by: Klaus Brune | last post by:
Hello all, When one tabs through a form (specifically, in Firefox), all the text in a field is automatically selected. What I'm looking for is a way to put a function (in onFocus perhaps)...
3
by: dugald.morrow | last post by:
I have some javascript that updates the text in a text field after certain actions take place such as clicking a checkbox. The javascript works fine in Safari and Firefox, but in IE, the text in...
6
by: Tony Johansson | last post by:
Hello! I'm reading in a book called Visual C# 2005. In the chapter about Generics there ia a section about Nullable types. Here is the text that isn't complete true I think. It says: "You...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.