This is a discussion on "[SOLVED] Extract text from a dropdown field? Hmm..." within the JavaScript Forum section. This forum, and the thread "[SOLVED] Extract text from a dropdown field? Hmm... are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
[SOLVED] Extract text from a dropdown field? Hmm...
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
Hi everyone,
I'm not sure if what I want to do is possible, but I hope it is! Would anybody be able to help me? I have a dropdown menu with a number of options. For the text that is displayed for each option, it looks something like: [123456] Some text - Some more text What I would like to do, is extract just the text between '[' and ']'. I will then display this on the page. I know how to do this, but just need the correct text to display. I hope someone could help, becuase I've searched all over the internet and have found nothing! Many thanks |
|
|
|
||||
|
Re: Extract text from a dropdown field? Hmm...
If it will always be numbers you could use a simple regex...
alert(whereveryougetthetextfrom.match(/\[[0-9]*\]/));
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
|
|
|||
|
Re: Extract text from a dropdown field? Hmm...
It won't always be numbers
Is 'alert' to display a box that pops up? I thought it was (I don't know much about javascript though). When I said I wanted to display it somewhere else on the page, I meant that I would place a <span> and then change the contents of that using some code I found, involving 'innerhtml'. Many thanks |
|
||||
|
Re: Extract text from a dropdown field? Hmm...
Okay, so I was only using an alert to show how you would get the details...
If it will be in square brackets and only letters and numbers. you could use.
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
|
|
|||
|
Re: Extract text from a dropdown field? Hmm...
Aaaah okay, sorry.
Right I tried that but it didn't work, so I had a little fiddle around with the code and got it to work. What I ended up with was:
Simon |
![]() |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| making text field text disapear | Phixon | JavaScript Forum | 4 | Feb 2nd, 2008 07:49 |
| [SOLVED] Text field & list menu size problem | longstand | Web Page Design | 2 | Nov 1st, 2007 12:38 |
| Non-text field Validation | NewDesigner | JavaScript Forum | 6 | Nov 24th, 2006 22:34 |
| validate text field to db field | jtesolin | Classic ASP | 1 | Jul 18th, 2006 17:48 |
| Building Text/Dropdown Menu w/ no background | TruBluTex | Flash & Multimedia Forum | 8 | Jan 15th, 2006 20:54 |