Results 1 to 4 of 4

Thread: HTML: How to pass 2 values in a form & clear input box on selection

  1. #1
    Squeeler Vini's Avatar
    Join Date
    Jul 2003
    Location
    Sheffield
    Posts
    1,769
    Thanks
    44
    Thanked
    8 times in 8 posts

    HTML: How to pass 2 values in a form & clear input box on selection

    Anyone know how I can pass two values when submitting an HTML form...

    My edited code is

    PHP Code:
    print "<form method=\"get\" action=\"$PHP_SELF\">
        <input class=\"box\" name=\"address\" size=\"20\" value=\"
    $address\">";
        if (
    count($groups) > 1) print "<option value=\"modify\">".$CCMAIL_LANG['modify']."</option>";
        print 
    "</select><input type=\"submit\" value=\"".$CCMAIL_LANG['go']."\" class=\"button\">"
    whilst the original is

    PHP Code:
        print "<form method=\"get\" action=\"$PHP_SELF\"><b>" $CCMAIL_LANG['insert_addr'] ."</b>
        <font color=\"red\"><b>
    $error_message</b></font><br><br>
        <input name=\"address\" size=\"20\" value=\"
    $address\" class=\"tbox_max\"><select name=\"action\" class=\"tbox\">
        <option value=\"subscribe\" selected>"
    .$CCMAIL_LANG['subscribe']."</option>
        <option value=\"unsubscribe\">"
    .$CCMAIL_LANG['unsubscribe']."</option>";
        if (
    count($groups) > 1) print "<option value=\"modify\">".$CCMAIL_LANG['modify']."</option>";
        print 
    "</select><input type=\"submit\" value=\"".$CCMAIL_LANG['go']."\" class=\"button\"><br><br>"
    basically I've just removed the drop down, with options 'Subscribe' and 'Unsubscribe'... I just want the user to be forced to subscribe if they enter their details, how can I pass the value 'subscribe' in my edited form?


    Also, any idea how to clear the box of its contents when it is selected? Is this a java snippet?

  2. #2
    Theoretical Element Spud1's Avatar
    Join Date
    Jul 2003
    Location
    North West
    Posts
    7,508
    Thanks
    336
    Thanked
    320 times in 255 posts
    • Spud1's system
      • Motherboard:
      • Gigabyte Aorus Master
      • CPU:
      • 9900k
      • Memory:
      • 16GB GSkill Trident Z
      • Storage:
      • Lots.
      • Graphics card(s):
      • RTX3090
      • PSU:
      • 750w
      • Case:
      • BeQuiet Dark Base Pro rev.2
      • Operating System:
      • Windows 10
      • Monitor(s):
      • Asus PG35VQ
      • Internet:
      • 910/100mb Fibre
    you could add in a hidden form...like this:

    <input type="hidden" name="Subscribe" value="Subscribe" />

    and that value should be passed.

    You should also fix your html code...your missing closing '/'s all over the place...remember to close your input tags with a />

    as for clearing the contents I think thats a javascript snippet...not sure

  3. #3
    Senior Member Kezzer's Avatar
    Join Date
    Sep 2003
    Posts
    4,863
    Thanks
    12
    Thanked
    5 times in 5 posts
    Yes it's JavaScript, not Java. Remember, Java != JavaScript.

  4. #4
    Member
    Join Date
    Jan 2007
    Location
    Manchester
    Posts
    56
    Thanks
    0
    Thanked
    0 times in 0 posts
    To clear an input box when it's selected use something like:

    PHP Code:
      <input id="testbox" value="default" onFocus="document.getElementById('testbox').value = '';"
    Remember that this will clear it each you select it. If you want it only to be cleared the first time it's selected, use:

    PHP Code:
    <input id="testbox" value="default" onFocus="if (document.getElementById('testbox').value == 'default') {document.getElementById('testbox').value = '';}"

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Puzzle - which door?
    By Paul Adams in forum General Discussion
    Replies: 90
    Last Post: 23-11-2008, 06:05 PM
  2. JavaScript enabled input box
    By Kezzer in forum Software
    Replies: 3
    Last Post: 13-09-2005, 07:16 PM

Posting Permissions

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