Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > wrong variable in text field in firefox

Reply
Thread Tools

wrong variable in text field in firefox

 
 
JaRudzik
Guest
Posts: n/a
 
      03-22-2006
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>");
// -------------------------------------------------------------------------
----
?>



 
Reply With Quote
 
 
 
 
Randy Webb
Guest
Posts: n/a
 
      03-22-2006
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/
 
Reply With Quote
 
 
 
 
JaRudzik
Guest
Posts: n/a
 
      03-22-2006
http://www.studio-er.home.pl/test_form.php

for testing

BR.
Rafal


 
Reply With Quote
 
JaRudzik
Guest
Posts: n/a
 
      03-23-2006
OK I resolved that
my own

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

BR
Rafał



Użytkownik "JaRudzik" <(E-Mail Removed)> napisał w wiadomości
news:dvr6n8$k7h$(E-Mail Removed)...
> http://www.studio-er.home.pl/test_form.php
>
> for testing
>
> BR.
> Rafal
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
javascript validation for a not required field, field is onlyrequired if another field has a value jr Javascript 3 07-08-2010 10:33 AM
1.Enter space bar for field names and save the field.The field shoud not get saved and an alert should be there as"Space bars are not allowed" Sound Javascript 2 09-28-2006 02:43 PM
Placing the selection of a list field in a text field Jerry Manner HTML 5 06-09-2005 01:52 PM
writing from hidden field to text field Roy Adams Javascript 1 12-20-2004 03:47 AM
Changing drop-down field to text field. ehm Javascript 2 09-24-2003 07:00 PM



Advertisments