HTML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb DesignHTML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 30th, 2000, 04:01 PM
bbarker bbarker is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2000
Posts: 25 bbarker User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation 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

Reply With Quote
  #2  
Old July 1st, 2000, 01:01 AM
firepages's Avatar
firepages firepages is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Feb 2000
Location: Perth West Australia
Posts: 741 firepages User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
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

Reply With Quote
  #3  
Old July 1st, 2000, 01:06 PM
bbarker bbarker is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2000
Posts: 25 bbarker User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation 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>

Reply With Quote
  #4  
Old July 1st, 2000, 10:28 PM
firepages's Avatar
firepages firepages is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Feb 2000
Location: Perth West Australia
Posts: 741 firepages User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
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

Reply With Quote
  #5  
Old July 2nd, 2000, 09:51 PM
bbarker bbarker is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2000
Posts: 25 bbarker User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation 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

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignHTML Programming > Clearing a form field once it's been populated by an onClick?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway