#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2000
    Posts
    25
    Rep Power
    0
    I'm using an onClick event to populate a text box with an x. Is there a way to use a separate or the same script to clear the box (or replace with a space) the next time the text box is clicked on? Thanks in advance.
    Bob
  2. #2
  3. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    Perth West Australia
    Posts
    757
    Rep Power
    15
    document.formname.fieldname.value="" is the bit you probably already know - we would need to see your code to see the best way to implement it.

    does the value change with an onclick on the text box ? or elsewhere - if elsewhere you can then call the clearing code above with an onfocus() or onclick() event in the input field itself.

    ------------------
    Simon Wheeler
    FirePages -DHTML/PHP/MySQL
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2000
    Posts
    25
    Rep Power
    0
    I'm including a couple of the fields from the form in question. Basically, what I have is a tool for my company that allows someone to fill out the form, print and email it for a price quote.

    As there can be multiple service points for each order, I went with an array to capture the data. I couldn't use check boxes or drop lists because neither could pass a value for the unchecked/unselected items. Consequently, upon submission, the data input was not accurate because everything shifted to fill the voids. So, I decided to do a text box/check box and give the sales people back a measure of the functionality of the check boxes.

    The onClick I used has been modified from a script that opened an alert window - I just futzed with it until it works. So, I don't know for certain if it's the best solution ot not. I really appreciate your efforts to date. Thanks.

    Bob
    ******************************************
    <?$i=0?>
    <form method="post" name="salesForm" action="salesForm.phtml" onSubmit="return CheckForm();">

    <?while ($i< 2):?>

    Location <?echo ($i+1)?>:&nbsp;<input type="text" size="1" name="dldckDS1[]" onClick="document.salesForm.x;value='x';return true;" value="<?echo $dldckDS1[$i]?>">&nbsp;DS-1 (T1)
    &nbsp;&nbsp;
    <input type="text" size="1" name="dldckDS3[]" onClick="document.salesForm.x;value='x';return true;" value="<?echo $dldckDS3[$i]?>">&nbsp;DS-3 (T3)
    <p>
    <?$i++?>

    <?endwhile?>
    </form>
  6. #4
  7. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    Perth West Australia
    Posts
    757
    Rep Power
    15
    not sure why you can not use a checkbox? - but anyway the code below works.

    You will have to use this format as you are generating inputs via a loop, just echo the name of the field & the value of check() and it should work for a 100 textboxes.

    <html>
    <head>
    <script>
    function check(fvar){
    var formval='document.formname.'+fvar+'.value';
    (!eval(formval))?newval='document.formname.'+fvar+'.value="x"'
    :newval='document.formname.'+fvar+'.value=""';
    eval(newval);
    }
    </script>
    </head>
    <style>
    </style>
    <body bgcolor="#ffffff">
    <form name=formname>
    <input type=text name=fname onclick="check('fname')">
    </form>
    </body>
    </html>

    PS: remember that in Netscape - you have to address a form in a div or layer explicitly - ie: document.formname.name.value in a <div id="thisdiv"> becomes document.thisdiv.document.formname.name.value

    Hope this helps
    Regards,

    Simon.


    ------------------
    Simon Wheeler
    FirePages -DHTML/PHP/MySQL
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2000
    Posts
    25
    Rep Power
    0
    Thanks. This looks great. I wish I could use a checkbox - tried to initially but my data went nuts after the submit and lost with elements were not checked. What happened was:
    Before submit:
    ck1 ck2
    1st record x
    2nd record x

    After submit:
    ck1 ck2
    1st record x x
    2nd record

    I tried all sorts of things but could never figure out how to give an un-selected checkbox a value in an array it was okay as a single record but would no work in an array - selection lists were the same. I'll keep looking long term because I know there's an answer to it but will have to go with this to make deadline. Thank you, thank you for all your help.

    Bob

Similar Threads

  1. Replies: 8
    Last Post: January 8th, 2005, 11:25 AM
  2. Inserting from form to multiple tables
    By barth in forum MySQL Help
    Replies: 0
    Last Post: January 25th, 2004, 09:27 AM
  3. HTTP Error 400: Bad Request, with basic form
    By crackwombat in forum PHP Development
    Replies: 1
    Last Post: January 23rd, 2004, 06:40 PM
  4. sending form field data
    By bellcom in forum PHP Development
    Replies: 1
    Last Post: January 19th, 2004, 03:39 PM
  5. (help request :)) JavaScript function (reformat form field value)
    By kr381v in forum JavaScript Development
    Replies: 4
    Last Post: September 21st, 2003, 01:53 AM

IMN logo majestic logo threadwatch logo seochat tools logo