SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Addict
    Join Date
    Aug 2005
    Location
    Belgium
    Posts
    387
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    onclick remove the text in form + hisde part of form

    Hi there
    I have this form on my proxy:
    Code:
      <form name="<?php echo $PHProxy->config['proxy_url_form_name'] ?>" method="get" action="<?php echo $_SERVER['PHP_SELF'] ?>">
      <input type="hidden" name="<?php echo $PHProxy->config['url_var_name'] ?>" value="" id="url_input" />
      <input type="hidden" name="<?php echo $PHProxy->config['flags_var_name'] ?>" value="" />
      </form>
      <form name="<?php echo $PHProxy->config['proxy_settings_form_name'] ?>" method="get" action="" onsubmit="return submit_form();">
      <table style="width: 100%">
      <tr><td class="option" style="width: 20%">URL</td><td class="option" style="width: 80%">&nbsp;<input type="text" name="url" size="70" value="" /></td></tr>
      <?php echo $PHProxy->options_list(true, true) ?>
      <tr><td class="option" style="width: 20%">New Window</td><td class="option" style="width: 80%"><input type="checkbox" name="new_window" />Open URL in a new window </td></tr>
      </table>
      <div style="text-align: center"><input type="submit" name="browse" value="Browse" onclick="return submit_form();" /></div>
      </form>
    I want that, ther is a text on the input form "typ URL here"
    Then if you click that box, the text goes away ...
    Also that the options aren't visibel, but only the form where you write the url, the other options have to become visibel when you click on a text link "Advanced"

    Can someone do this for me please ?
    I don't know anything about JS

    Tahnks alot

  2. #2
    SitePoint Wizard chris_fuel's Avatar
    Join Date
    May 2006
    Location
    Ventura, CA
    Posts
    2,751
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Shove this someplace in the <head> tag:

    Code:
    <script type="text/javascript">
    function textClear(element)
    {
      if ( element.value != '' )
      {
          element.value = '';
      }
    }
    </script>
    Then just:

    HTML Code:
    <input type="text" .... onclick="textClear(this);">....

  3. #3
    SitePoint Wizard chris_fuel's Avatar
    Join Date
    May 2006
    Location
    Ventura, CA
    Posts
    2,751
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hmm, actually this was more like it but..

    Code:
    function clearText(element)
    {
            if ( !element.was_clicked )
            {
                    element.value = '';
                    element.was_clicked = true;
            }
    }
    it seems to work in firefox, but JavaScript console is throwing some obscure error message that I've never seen before..

  4. #4
    SitePoint Addict
    Join Date
    Aug 2005
    Location
    Belgium
    Posts
    387
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks
    but it isn't working
    http://myspaceproxy1.com/
    I added it, but nothing happens ...

  5. #5
    SitePoint Addict
    Join Date
    Aug 2005
    Location
    Belgium
    Posts
    387
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    please someone ?

  6. #6
    SitePoint Member
    Join Date
    Jun 2006
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    in the header somewhere stick the following:

    HTML Code:
    <script language="javascript" type="text/javascript">
    var is_clicked=false;
    function clear_input(element){
        if (is_clicked) element.value="";
    }
    
    function show_hide_options(element){
        element.style.display=(element.style.display="none"?"block":"none");
    }
    </script>
    Make the code for the input box:

    HTML Code:
    <input type="text" name="url" size="70" value="" onclick="clear_input(this);is_clicked=true" />
    Also, wrap your options with a div:
    HTML Code:
    <div id="advanced" name="advanced" style="display:none"> ...insert options... </div>
    And stick in an advanced button:
    HTML Code:
    <input type="button" onclick="show_hide_options(advanced)" value="Advanced" />
    should work, hasnt been tested tho

    good luck

  7. #7
    SitePoint Wizard chris_fuel's Avatar
    Join Date
    May 2006
    Location
    Ventura, CA
    Posts
    2,751
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That would work, but you would need to do this instead:

    onclick="clear_input(this);if (!is_clicked) { is_clicked=true; }"

  8. #8
    SitePoint Member
    Join Date
    Jun 2006
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    y??
    it shouldnt matter as it just makes sure that the variable is still set to true, it juts clutters ur code

  9. #9
    SitePoint Member
    Join Date
    Jul 2006
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    2 Clicks

    I've implemented the most recent code block and I have to click in the input box twice to get the text to disappear. This happens in both IE 7 and Firefox.

  10. #10
    SitePoint Addict
    Join Date
    Aug 2005
    Location
    Belgium
    Posts
    387
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I tryed both guys, none of them seems to work for me :s

    here they are online: http://www.myspaceproxy1.com/v2/

    please help someone ?

    thanks


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
  •