wrong variable in text field in firefox

Discussion in 'Javascript' started by JaRudzik, Mar 22, 2006.

  1. JaRudzik

    JaRudzik Guest

    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>");
    // -------------------------------------------------------------------------
    ----
    ?>
     
    JaRudzik, Mar 22, 2006
    #1
    1. Advertising

  2. JaRudzik

    Randy Webb Guest

    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/
     
    Randy Webb, Mar 22, 2006
    #2
    1. Advertising

  3. JaRudzik

    JaRudzik Guest

    JaRudzik, Mar 22, 2006
    #3
  4. JaRudzik

    JaRudzik Guest

    Re: wrong variable in text field in firefox + URL :)

    OK I resolved that
    my own :)

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

    BR
    Rafa³



    U¿ytkownik "JaRudzik" <> napisa³ w wiadomo¶ci
    news:dvr6n8$k7h$...
    > http://www.studio-er.home.pl/test_form.php
    >
    > for testing
    >
    > BR.
    > Rafal
    >
    >
     
    JaRudzik, Mar 23, 2006
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jerry Manner
    Replies:
    5
    Views:
    570
    Jonathan N. Little
    Jun 9, 2005
  2. ehm
    Replies:
    2
    Views:
    209
  3. Roy Adams

    writing from hidden field to text field

    Roy Adams, Dec 20, 2004, in forum: Javascript
    Replies:
    1
    Views:
    208
  4. Sound
    Replies:
    2
    Views:
    465
    Randy Webb
    Sep 28, 2006
  5. jr
    Replies:
    3
    Views:
    450
Loading...

Share This Page