wrong variable in text field in firefox

J

JaRudzik

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='';><img 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).".value='';><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>");
// -------------------------------------------------------------------------
 
R

Randy Webb

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.
 
J

JaRudzik

OK I resolved that
my own :)

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

BR
Rafa³
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,744
Latest member
CortneyMcK

Latest Threads

Top