Client Side Things
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesClient Side Things

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 Codewalkers Forums Sponsor:
  #1  
Old February 22nd, 2004, 07:10 AM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
checkbox to govern dynamic form fields

I am working on a form in php/HTML that gathers input from a user that is then written to a mySQL database. I need something similar to what is used on so many web sites where you are asked whether your billing address is also your ship to address and if you check yes, the shipt to fields are auto filled with what you have put in for the billing fields. I am using a checkbox on the form that I want the user to check if two addresses are the same. If the user checks the box, I want the second address fields (newfield) to be autofilled based on the first address fields (oldfield).

I tried doing it with an onClick embedded in the HTML where I check that the value of the checkbox is checked and then I set the newfield.value=oldfield.value. I don't have the code on this machine so I'm not posting it tonight but when the box is checked, no auto population is occuring from the old address fields that are filled in already to the second address fields that have not been filled in.

I am sure this is not a difficult task and I assume it can be done with only HTML and php or do I need to look at using js?

Thank you


Reply With Quote
  #2  
Old February 23rd, 2004, 05:46 AM
white_fang white_fang is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 4 white_fang User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: checkbox to govern dynamic form fields

usually, you can just use the same variables/fields to insert values into your DB.

try writing a script which runs this algorithm. if billing chkbox = true, use the same values for billing address from shipping address.

consequently, you can tag these entries with a flag called bill_ship or something similar.

Reply With Quote
  #3  
Old February 23rd, 2004, 06:19 AM
nawlej nawlej is offline
Contributing User
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: Dallas, Tx. USA
Posts: 2,008 nawlej User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 7 m 51 sec
Reputation Power: 4
RE: checkbox to govern dynamic form fields

Well, you are definitely going to have to use javascript for the autopopulation. PHP pretty much wont help you in this case because all of its parsing is done server side. It will be a greater help when you post the code. I would be more than happy to write some javascript to accomodate that for you.

Reply With Quote
  #4  
Old February 23rd, 2004, 06:20 AM
System System is offline
Codewalkers Novice (500 - 999 posts)
 
Join Date: Apr 2007
Posts: 665 System User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Message Moved

Thread moved from 'PHP Coding' to 'Client Side Things' by nawlej.

Reason: form population issue.......

Reply With Quote
  #5  
Old March 4th, 2004, 10:05 PM
Symbeon Symbeon is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 18 Symbeon User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: checkbox to govern dynamic form fields

You might want to try prefixing the call in you onclick event with javascript:

I have noticed things will sometimes not work correctly without it.

Another thing is to put document.form_name. in front of the field names.

Last, you could put the code to do this in a function and call that function from the onclick event. This is probably not necessary if you are only copying one value.

Reply With Quote
  #6  
Old March 5th, 2004, 12:33 AM
CodeKadiya CodeKadiya is offline
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: Colombo,Sri Lanka
Posts: 2,313 CodeKadiya User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 4
Send a message via Yahoo to CodeKadiya
RE: checkbox to govern dynamic form fields

Played around with it.. this should work!!!
Code:
<form name="testform">
Address 1 : <input type="text" name="address1"><br>
Address 2 : <input type="text" name="address2"><br>
<input type="checkbox" onClick="if(this.checked==true) { document.testform.address2.value=document.testform  .address1.value; } else { document.testform.address2.value=''; }">
</form>

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesClient Side Things > checkbox to govern dynamic form fields


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 5 hosted by Hostway
Stay green...Green IT