TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 06-08-2009, 07:02 AM   #1 (permalink)
The Wanderer
 
sandhyagupta's Avatar
 
Join Date: Jun 2009
Posts: 20
Thanks: 4
sandhyagupta is on a distinguished road
Default Can anyone help me

hi everyone,

I new to javascript.here s my objective:
!)i need to create a form with few fields like phoneno,website,address etc and one text area.
2) i copy n paste the details in the textarea n when i click d button. it should automatically populate things into the respective fields.
here s my logic wt i taught of:
1)read the first line in the textbox and load it into contact person field.
2)find the @ symbol and put it into the respective field and if there are more than 1 mail id load it into the same feild using commas.
3)if the phone no is 10 digits then load it into the mobile field else load the rest it into phone field.
4)find for words like road,street,block,stage,floor etc,if present then load it into the address field till the last comma is encountered.
5)the last digits in the address should be loaded into the pincode field.
6)the last word present in the address after the last comma and before the hyphen should be loaded into the city field.
7)find for www or http and load it into the website field,if not found leave it blank.

but m not able to code.. can anyone plz help me out to code.
sandhyagupta is offline  
Reply With Quote
Old 06-08-2009, 10:33 AM   #2 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

Would it not be better to get your users to fill in individual boxes? Whilst this is possible with regular expressions, you may well encounter unforeseen issues when parsing the data, and thus giving you bad data.
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Old 06-09-2009, 04:29 AM   #3 (permalink)
The Wanderer
 
sandhyagupta's Avatar
 
Join Date: Jun 2009
Posts: 20
Thanks: 4
sandhyagupta is on a distinguished road
Default

thanks a lot.yeah i knw u r rite but my company wants it. m trying my best to code but m nt able to come up wit the result. so if u can send me piece of code that would serve a lot.. thanks once again.


Quote:
Originally Posted by Wildhoney View Post
Would it not be better to get your users to fill in individual boxes? Whilst this is possible with regular expressions, you may well encounter unforeseen issues when parsing the data, and thus giving you bad data.
sandhyagupta is offline  
Reply With Quote
Old 06-08-2009, 06:39 PM   #4 (permalink)
The Addict
 
tony's Avatar
 
Join Date: Aug 2008
Posts: 336
Thanks: 8
tony is on a distinguished road
Default

this kind of smart text recognition, leaves too much room for mistakes or empty matches of the strings that you are looking for, like wildhoney said.
It would be best to avoid it, but if you really need to do it, I think you would need more concise rules for the different text matches that you have, to make it possible, but that would still leave some room for bad data or user mistakes and that would leave to bad user experience if they expect that.
tony is offline  
Reply With Quote
Old 06-09-2009, 04:32 AM   #5 (permalink)
The Wanderer
 
sandhyagupta's Avatar
 
Join Date: Jun 2009
Posts: 20
Thanks: 4
sandhyagupta is on a distinguished road
Default

hi tony,
ya u were rite.but my company s demanding for it. i am trying my best to come up with d result. but m nt able to . so if u knw could u plz guide me through it. thanks in advance.
sandhyagupta is offline  
Reply With Quote
Old 06-09-2009, 11:16 AM   #6 (permalink)
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

Tell your company that it is a stupid idea and offer a more suitable alternative, if necessary come to a compromise. If you really, really, really must do what you are asking in the first post then have a go at it and show them how woefully inadequate such a system would be.
Salathe is offline  
Reply With Quote
Old 06-12-2009, 11:56 AM   #7 (permalink)
The Prestige
Advanced Programmer Top Contributor Good Samaritan 
 
sketchMedia's Avatar
 
Join Date: Oct 2007
Location: Manchester, UK
Posts: 854
Thanks: 32
sketchMedia is on a distinguished road
Default

Quote:
If you really, really, really must do what you are asking in the first post then have a go at it and show them how woefully inadequate such a system would be.
Yep, from my experience some people will ONLY learn from their mistakes and bad decisions, and won't take in the advice a seasoned web developer gifts them which in my opinion is a very reckless and dim-witted approach to development IMO.
For people like that, arguing won't get you very far so you must show them the errors of their ways, obviously this means more work for you but in the long run the right decision will be made thus resulting in a much easier/cleaner and safer code-base.
__________________
mysql> SELECT * FROM `users` WHERE `users`.`clue` > 0;
Empty set (0.00 sec)
sketchMedia is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 03:26 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design