www.webdeveloper.com
Results 1 to 2 of 2

Thread: error, never used CSS before

  1. #1
    Join Date
    Jul 2006
    Posts
    23

    resolved [RESOLVED] error, never used CSS before

    i'm trying to get a tutorial that gave bad instructions to work, i think this is the last thing i need.

    Code:
    
    <input id="username" name="username" type="text" onblur="checkName(this.value,'') "/>
    <span class="hidden" id="nameCheckFailed">
      This name is in use, please try another.
    </span>
    
    span.hidden
    {
        display: none;
    }
    span.error
    {
        display: inline;
        color: black;
        background-color: pink;
    }
    
    <?php
    echo'
    <SCRIPT LANGUAGE="JavaScript">
    <!--
    var req;
    
    function loadXMLDoc(url)
    {
        // branch for native XMLHttpRequest object
        if (window.XMLHttpRequest) {
            req = new XMLHttpRequest();
            req.onreadystatechange = processReqChange;
            req.open("GET", url, true);
            req.send(null);
        // branch for IE/Windows ActiveX version
        } else if (window.ActiveXObject) {
            req = new ActiveXObject("Microsoft.XMLHTTP");
            if (req) {
                req.onreadystatechange = processReqChange;
                req.open("GET", url, true);
                req.send();
            }
        }
    }
    //-->
    </SCRIPT>'
    ?>
    
    
    <SCRIPT LANGUAGE="JavaScript">
    <!--
    function checkName(input,response)
    {
        if (response != '')
        {
            //Response move
            message = document.getElementById('nameCheckFailed');
            if (response == '1')
            {
                message.className = 'error';
            }
            else
            {
                message.className = 'hidden';
            }
        }
        else
        {
            //Input mode
            url = 'http://localhost/newic/checkUserName.php?q=' + input;
            loadXMLDoc(url);
        }
    }
    //-->
    </SCRIPT>
    
    <?php echo'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <response>
              <method>checkName</method>
              <result>1</result>
    </response>';
    ?>
    <SCRIPT LANGUAGE="JavaScript">
    <!--
    function processReqChange()
    {
        //online if req shows "complete"
        if (req.readyState == 4)
        {
            //only if "OK"
            if (req.status == 200)
            {
                //...processing statements go here...
                response = req.responseXML.documentElement;
    
                method   = response.getElementsByTagName('method')[0].firstChild.data;
    
                result   = response.getElementsByTagName('result')[0].firstChild.data;
    
                eval(method + '{\'\',result)');
            }
            else
            {
                alert("There was a problem retrieving the SM data:\n" + req.statusText);
            }
        }
    }
    //-->
    </SCRIPT>
    output is


    This name is in use, please try another. span.hidden { display: none; } span.error { display: inline; color: black; background-color: pink; } checkName 1


    it also has a text input box at the beginning
    Last edited by Red_Scene; 07-11-2006 at 11:06 PM.

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,616
    This portion...
    Code:
    span.hidden
    {
        display: none;
    }
    span.error
    {
        display: inline;
        color: black;
        background-color: pink;
    }
    ...belongs in the <style> block of your <head> section, or else in an external stylesheet -- not in the middle of your <body> section.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles