SitePoint Sponsor

User Tag List

Results 1 to 16 of 16
  1. #1
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Smile javascript onChange()

    How can I change this so that, if the user starts typeing it wont clear the text box. Also I need to check if the usernames are the same?

    Whats the best way to do this.


    PHP Code:
    <!-- ini setup file -->

    <?
        
    include("ini.php3");
        
    pageheader('ini setup file')

    ?>

    <script>
    function openPanel(option)
    {
        var adminpanel = open(option,'adminpanel','');
        adminpanel.focus();
    }

    function verifyUserCheck()
    {
        if (document.users.checkUser.checked==1)
        {
            if(document.users.updateUser.value=="" || document.users.verifyUser.value=="")
            {
                document.users.updateUser.value="Enter Username to ";
                document.users.verifyUser.value="change username";
                setTimeout('document.users.checkUser.checked=0;document.users.updateUser.value="";document.users.verifyUser.value="";document.users.updateUser.focus();',1000);
                window.status=(document.users.updateUser.value + document.users.verifyUser.value);
                if (document.users.updateUser.onchange())
                {
                alert ('changed');
                }
                else
                {
                setTimeout('window.status="' + document.users.updateUser.value + '"',1000);
                }
            }
            else if (document.users.updateUser.value=="Enter Username to " || document.users.verifyUser.value=="change username")
            {
                setTimeout('document.users.checkUser.checked=0',1000);
            }
            else if (document.users.updateUser.value!=document.users.verifyUser.value)
            {
                if (document.users.updateUser.value)
                setTimeout('document.users.checkUser.checked=0',1000);
            }
            else
            {
                setTimeout('document.users.checkUser.checked=0',1000);
            }
            
        }
        else
        {
            setTimeout('document.users.checkUser.checked=0',5000);
        }
    }
    </script>

    <body bgcolor='#FFFFFF' text='#FFFFFF' link='#000000' vlink='#000000' alink='#000000' topmargin='0' leftmargin='0'>
    <div align="center">
      <form name="users" method="post" action="">
        <table width="366" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
          <tr> 
            <td valign="middle" height="26" colspan="8" align="center" bgcolor="#000000">ini 
              setup file</td>
          </tr>
          <tr> 
            <td valign="top" height="19" colspan="8" align="center"> 
              <p><font color="#000000">Modify Setup</font></p>
            </td>
          </tr>
          <tr> 
            <td valign="top" height="19" colspan="3" bgcolor="#333333"> 
              <div align="center"><font color="#FFFFFF">description</font></div>
            </td>
            <td valign="middle" colspan="4" align="center" bgcolor="#333333"><font color="#FFFFFF">details</font></td>
            <td width="63" valign="top" bgcolor="#333333"> 
              <div align="center"><font color="#FFFFFF">update</font></div>
            </td>
          </tr>
          <tr> 
            <td valign="middle" height="28" align="left" bgcolor="#CCCCCC" colspan="3"> 
              <div align="left"><font color="#000000">Update Username</font></div>
            </td>
            <td valign="top" bgcolor="#CCCCCC" align="center" colspan="4"> <font color="#000000"> 
              <input type="text" name="updateUser" onchange='document.users.updateUser.value=document.users.updateUser.value'>
              </font> <font color="#000000"> </font> <font color="#000000"> </font></td>
            <td valign="top" bgcolor="#CCCCCC">&nbsp;</td>
          </tr>
          <tr> 
            <td height="28" valign="middle" colspan="3" align="left"> 
              <div align="left"><font color="#000000">Verify</font> <font color="#000000">Username</font></div>
            </td>
            <td valign="top" colspan="4"> 
              <div align="center"><font color="#000000"> 
                <input type="text" name="verifyUser">
                </font></div>
            </td>
            <td valign="top"> 
              <div align="center"> 
                <input type="checkbox" name="checkUser" onclick="verifyUserCheck()">
              </div>
            </td>
          </tr>
          <tr> 
            <td height="28" valign="middle" align="left" bgcolor="#999999" colspan="3"> 
              <div align="left"><font color="#000000">Update Password</font></div>
            </td>
            <td valign="top" bgcolor="#999999" align="center" colspan="4"><font color="#000000"> 
              <input type="password" name="updatePass">
              </font></td>
            <td valign="top" bgcolor="#999999"> 
              <div align="center"></div>
            </td>
          </tr>
          <tr> 
            <td height="28" valign="middle" colspan="3" align="left"> 
              <div align="left"><font color="#000000">Verify Password</font></div>
            </td>
            <td valign="top" colspan="4"> 
              <div align="center"><font color="#000000"> 
                <input type="password" name="verifyPass">
                </font></div>
            </td>
            <td valign="top" align="center"> 
              <input type="checkbox" name="checkPass">
            </td>
          </tr>
          <tr> 
            <td height="21" valign="middle" colspan="8" bgcolor="#CCCCCC" align="center"> 
              <hr>
            </td>
          </tr>
          <tr> 
            <td height="19" valign="top" colspan="2"> 
              <div align="center"> <font color="#000000"> <b> <a href="javascript:void(0)" style="text-decoration:none" onclick="openPanel('pass.htm')">admin 
                panel</a> </b> </font> </div>
            </td>
            <td valign="top" colspan="2"> 
              <div align="center"> <a href="javascript:void(0)" style="text-decoration:none" onclick="openPanel('pass.htm')"> 
                <font color="#009933">New admin </font> </a> </div>
            </td>
            <td valign="top" colspan="2"> 
              <div align="center"> <a href="javascript:void(0)" style="text-decoration:none" onclick="openPanel('pass.htm')"> 
                <font color="#0000FF">Edit admin </font> </a> </div>
            </td>
            <td valign="top" width="65"> 
              <div align="center"> <a href="javascript:void(0)" style="text-decoration:none" onclick="openPanel('pass.htm')"> 
                <font color="#9900FF">List admin </font> </a> </div>
            </td>
            <td valign="top"> 
              <div align="center"> <a href="javascript:void(0)" style="text-decoration:none" onclick="openPanel('pass.htm')"> 
                <font color="#FF0000">Remove</font> </a> </div>
            </td>
          </tr>
          <tr> 
            <td height="21" colspan="8" valign="middle" bgcolor="#CCCCCC" align="center"> 
              <hr>
            </td>
          </tr>
          <tr> 
            <td height="13" width="78"></td>
            <td width="20"></td>
            <td width="23"></td>
            <td width="52"></td>
            <td width="48"></td>
            <td width="17"></td>
            <td></td>
            <td></td>
          </tr>
        </table>
      </form>
    </div>
    <p align="center"><font color="#000000">// settings </font> </p>
    <p align="center"><font color="#000000">$dbhost ='localhost';<br>
      $dbuser ='';<br>
      $dbpassword ='';<br>
      $db ='forum';</font></p>
    <p align="center"><font color="#000000">// table names</font></p>
    <p align="center"><font color="#000000">$topics ='topics';<br>
      $replies ='replies';<br>
      $users ='users';<br>
      $management ='admin';</font></p>
    <p align="center"><font color="#000000">// globals</font></p>
    <p align="center"><font color="#000000">$sitename ='forum';<br>
      $dbversion ='1.0';<br>
      $DOMAIN_URL ='../';</font></p>
    <p align="center"><font color="#000000">// forum settings</font></p>
    <p align="center"><font color="#000000">$db_entries ='5';<br>
      $db_display_type ='forum';<br>
      $db_email ='false';<br>
      $url ='./index.php3';</font></p>
    <p align="center"><font color="#000000">// meta settings</font></p>
    <p align="center"><font color="#000000">$author ='Andrew Johnstone';<br>
      $smarttags ='true';<br>
      $keyword ='';<br>
      $description ='';<br>
      $rating ='general';<br>
      $robots ='index,follow';<br>
      $revisit ='';<br>
      $copyright ='';</font></p>
    <p align="center"><font color="#000000">$contentstyle ='';<br>
      $contenttype ='';<br>
      $expires ='';<br>
      $pragma ='no-cache';<br>
      $cache ='no-cache';<br>
      $imagetoolbar ='';</font></p>
    <p align="center"><font color="#000000"><br>
      // page settings</font></p>
    <p align="center"><font color="#000000">$title ='forum';<br>
      $delay ='2';<br>
      $db_css ='style.css';<br>
      $db_tablewidth ='55%';<br>
      $body_attributes ='';<br>
      $signature ='Created by Andrew Johnstone';</font></p>
    Last edited by Andrew-J2000; Mar 12, 2002 at 04:54.

  2. #2
    SitePoint Enthusiast
    Join Date
    Mar 2002
    Location
    Salt Lake City Utah
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    not sure I understand the point of this:

    'document.users.updateUser.value=document.users.updateUser.value'

  3. #3
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    for some reason without it the actual value does not update on change, so I tried that and it worked fine reading the current value. Not sure why it worked though, but works at least.

    Does anyone have any ideas how to fix my problem though

  4. #4
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Very busy

    I'd be delighted to help Andrew, but as always i'm very busy.

    If you could edit your post so i can see the objects being refered to and the important functions relating straight away (use bold and color or something)
    then i can help you, otherwise i don't have time to look at it and work out what's going on.

    Thanks


    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---

  5. #5
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok thanks, I think i've seen the problem, but could you let me know if it is possible to stop a timer ("setTimeout"), from counting down

  6. #6
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    several methods

    yeah, you could use one of several methods.
    You could do a:
    if (!kill) setTimeout ...

    and just set kill=true; when you want to end the funciton.

    OR you could have a reference for the timeout ( var tim=setTimeout...) and just do a clearTimeout(tim);

    I think the method you're using might be very long winded. Could you explain to me from scratch what you're trying to achieve in terms of effects and results?

    thanks

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---

  7. #7
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well here goes

    if the user checks a text box say username, and the username text box is empty or there verification textbox for the username it will display a error "Enter Username to " & "change username" in username textbox and the verification split. After a while the boxes should clear and show an empty box.


    Now Heres my problem.


    If the user starts to type in the textbox the textbox it clears after a certain amount of time emptying what they have wrote, so basically I need to check whether the user has started to type and cancel the timeout function to clear the textbox.

    Hope that makes sense

  8. #8
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Mostly

    When you say:
    "checks a textbox say username"

    Do you mean there is a checkbox which they tick to say they want to enter a username?

    I think i have an idea that would save a FAIR bit of work

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---

  9. #9
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yup thats what I meant.

    Good thing is you appear to have a unique way of doing things so i'd like to see how you would do this?

  10. #10
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Not tested (as per usual)

    <input type="checkbox"
    onclick=" (this.checked)?
    var tim=setInterval('sflash()', 600);
    :
    (tim)?clearInterval(tim):return false;"
    >
    Note:
    This is a logic bundle and is NOT tested. I've written it nicely, but in reality it would look like:
    "(this.checked?var tim=setInterval('sflash()', 600)tim)?clearInterval(tim):return false;"


    <input type="text" id="user_a"
    onfocus="fhandle();">
    <input type="text" id="user_b"
    onfocus="fhandle();">

    <script language="Javascript">

    var de = document.getElementById;
    var f_text = "Please enter your username";
    var s_text = "And confirm here";
    var timer = 0;
    var f_ta = f_text.split('');
    var s_ta = s_text.split('');

    function sflash(){
    pref="b";
    array="s"
    if (timer < f_ta.length){
    pref="a";
    array="f";
    }
    de('user_'+pref) += (eval(pref+'_ta'))[timer];
    timer++;
    if (timer==f_ta.lenght+s_ta.length){
    timer=0;
    de('user_a').innerHTML='';
    de('user_b').innerHTML='';
    }
    function fhandle(){
    clearInterval(tim);
    de('user_a').innerHTML='';
    de('user_b').innerHTML='';
    }
    </script>
    Now this is JUST an idea, and i've not tested it...but what it would/could do/look like would be fairly impressive.

    See if it fits your scheme.

    Let me know if you can't get it working and i'll do a mockup here.

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---

  11. #11
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hmmm, besides missing a few brackets, i cant seem to get this to work?

    tim undefined?

  12. #12
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    No problem.

    I'll do a mockup for you
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---

  13. #13
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Proof of concept

    .oO( or genius, depending how you think about it )

    j/king

    http://www.passway.org/boxes.html

    There you go.
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---

  14. #14
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hmmm even though its a good effect its not quite what I need

  15. #15
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Well what more?

    Well then you have something to look at.. tell me what it's not doing that you need it to, or what you need it to that it's not?

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---

  16. #16
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK, sorry I didn't finish my message earlier i got disconnected damn wireless internet


    I would of put this online for you to read what i'm trying to do but, my free host decided to delete my account

    I also simplified it

    PHP Code:
    ok I setup a little document for you to see what i'm after exactly and got rid of the crap that was in my first post

    <p>OK, heres what I need exactly.</p>
    <ol>
      <li>onload clear both text boxes and uncheck checkbox.</li>
      <li>check whether the text boxes are empty, on clicking the checkbox.</li>
      <li>if checkbox is empty or not equal to verifying the checkbox it will show 
        your ticker.</li>
      <li>if one textbox is filled out the ticker will only work in one textbox, leaving 
        the box they have filed out intact and showing in the empty textbox </li>
      <li>instead of the ticker repeating itself continuously, I want it to timeout 
        when the checkbox is clicked and clear the checkbox and the textbox'

        
    <ul>
          <
    liegafter 3-10 seconds of displaying the ticker it will empty the textboxes 
            
    and gain focus on the textbox,<br>
            
    that is either empty or the verify textbox if not eqaul to the username 
            text box
    . </li>
        </
    ul>
      </
    li>
      <
    li><font color="#FF0000">Main Problem</font> - if the user starts typing while 
        
    the timer has been activated to clear the checkbox and textboxsit will cancel 
        the timer 
    and the and will allow the user to continue typing. </li>
      <
    li>also test if the username has a limit to its inputso if the user sets 
        the limit to 0 in the source the user will be able to 
    use infinate amount 
        of characters where 
    as if they set it to 5 they can enter a password of upto 
        five characters 
    and also allow for a min value as well in the same way.</li>
    </
    ol>
    <
    p>
    <
    script>
    function 
    openPanel(option)
    {
        var 
    adminpanel open(option,'adminpanel','');
        
    adminpanel.focus();
    }

    function 
    verifyUserCheck()
    {
        if (
    document.users.checkUser.checked==1)
        {
            if(
    document.users.updateUser.value=="" || document.users.verifyUser.value=="" || document.users.updateUser.value=="Enter Username to " || document.users.verifyUser.value=="change username" || document.users.updateUser.value!=document.users.verifyUser.value)
            {
                
    document.users.updateUser.value="Enter Username to ";document.users.verifyUser.value="change username";
                
    setTimeout('document.users.checkUser.checked=0;document.users.updateUser.value="";document.users.verifyUser.value="";document.users.updateUser.focus();',1000);
            }
            else
                
    document.users.submit();
        }
    }
    </script>
    </p>
    <div align="center">
      <form name="users" method="get" action="">
        <table width="366" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
          <tr> 
            <td valign="middle" height="26" colspan="8" align="center" bgcolor="#000000">ini 
              setup file</td>
          </tr>
          <tr> 
            <td valign="top" height="19" colspan="8" align="center"> 
              <p><font color="#000000">Modify Setup</font></p>
            </td>
          </tr>
          <tr> 
            <td valign="top" height="19" colspan="3" bgcolor="#333333"> 
              <div align="center"><font color="#FFFFFF">description</font></div>
            </td>
            <td valign="middle" colspan="4" align="center" bgcolor="#333333"><font color="#FFFFFF">details</font></td>
            <td width="63" valign="top" bgcolor="#333333"> 
              <div align="center"><font color="#FFFFFF">update</font></div>
            </td>
          </tr>
          <tr> 
            <td valign="middle" height="28" align="left" bgcolor="#CCCCCC" colspan="3"> 
              <div align="left"><font color="#000000">Update Username</font></div>
            </td>
            <td valign="top" bgcolor="#CCCCCC" align="center" colspan="4"> <font color="#000000"> 
              <input type="text" name="updateUser" onchange='document.users.updateUser.value=document.users.updateUser.value'>
              </font> <font color="#000000"> </font> <font color="#000000"> </font></td>
            <td valign="top" bgcolor="#CCCCCC">&nbsp;</td>
          </tr>
          <tr> 
            <td height="28" valign="middle" colspan="3" align="left"> 
              <div align="left"><font color="#000000">Verify</font> <font color="#000000">Username</font></div>
            </td>
            <td valign="top" colspan="4"> 
              <div align="center"><font color="#000000"> 
                <input type="text" name="verifyUser">
                </font></div>
            </td>
            <td valign="top"> 
              <div align="center"> 
                <input type="checkbox" name="checkUser" onclick="verifyUserCheck()">
              </div>
            </td>
          </tr>
          <tr> 
            <td height="28" valign="middle" align="left" bgcolor="#999999" colspan="3"> 
              <div align="left"><font color="#000000">Update Password</font></div>
            </td>
            <td valign="top" bgcolor="#999999" align="center" colspan="4"><font color="#000000"> 
              <input type="password" name="updatePass">
              </font></td>
            <td valign="top" bgcolor="#999999"> 
              <div align="center"></div>
            </td>
          </tr>
          <tr> 
            <td height="28" valign="middle" colspan="3" align="left"> 
              <div align="left"><font color="#000000">Verify Password</font></div>
            </td>
            <td valign="top" colspan="4"> 
              <div align="center"><font color="#000000"> 
                <input type="password" name="verifyPass">
                </font></div>
            </td>
            <td valign="top" align="center"> 
              <input type="checkbox" name="checkPass">
            </td>
          </tr>
          <tr> 
            <td height="21" valign="middle" colspan="8" bgcolor="#CCCCCC" align="center"> 
              <hr>
            </td>
          </tr>
          <tr> 
            <td height="19" valign="top" colspan="2"> 
              <div align="center"> <font color="#000000"> <b> <a href="javascript:void(0)" style="text-decoration:none" onclick="openPanel('pass.htm')">admin 
                panel</a> </b> </font> </div>
            </td>
            <td valign="top" colspan="2"> 
              <div align="center"> <a href="javascript:void(0)" style="text-decoration:none" onclick="openPanel('pass.htm')"> 
                <font color="#009933">New admin </font> </a> </div>
            </td>
            <td valign="top" colspan="2"> 
              <div align="center"> <a href="javascript:void(0)" style="text-decoration:none" onclick="openPanel('pass.htm')"> 
                <font color="#0000FF">Edit admin </font> </a> </div>
            </td>
            <td valign="top" width="65"> 
              <div align="center"> <a href="javascript:void(0)" style="text-decoration:none" onclick="openPanel('pass.htm')"> 
                <font color="#9900FF">List admin </font> </a> </div>
            </td>
            <td valign="top"> 
              <div align="center"> <a href="javascript:void(0)" style="text-decoration:none" onclick="openPanel('pass.htm')"> 
                <font color="#FF0000">Remove</font> </a> </div>
            </td>
          </tr>
          <tr> 
            <td height="21" colspan="8" valign="middle" bgcolor="#CCCCCC" align="center"> 
              <hr>
            </td>
          </tr>
          <tr> 
            <td height="13" width="78"></td>
            <td width="20"></td>
            <td width="23"></td>
            <td width="52"></td>
            <td width="48"></td>
            <td width="17"></td>
            <td></td>
            <td></td>
          </tr>
        </table>
      </form>
    </div> 


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •