Digital Point Forums
Winn and Sims

Go Back   Digital Point Forums > Design & Development > Programming > JavaScript
Google Analytics
Log In to view
your analytics

Reply
 
Thread Tools
  #1  
Old Apr 11th 2004, 7:06 pm
dave ner0tic dave ner0tic is offline
Peon
 
Join Date: Apr 2004
Posts: 1
dave ner0tic is on a distinguished road
javascript, php accessing form elements

I have a form with select form elements named mb[] so that they will be an array for the results page (php) to access.

I have a checkbox that when checked enables the select fields to be enabled.

my problem is accessing the select elements because they're named mb[]

how can i do this?
Reply With Quote
  #2  
Old Apr 11th 2004, 7:27 pm
relaxzoolander's Avatar
relaxzoolander relaxzoolander is offline
Champion of the Naaru
 
Join Date: Apr 2004
Location: columbus, ohio
Posts: 141
relaxzoolander is on a distinguished road
can you post the relevant code.
thanks.
Reply With Quote
  #3  
Old Apr 12th 2004, 12:25 am
er2er er2er is offline
Peon
 
Join Date: Apr 2004
Posts: 9
er2er is on a distinguished road
You can either use "document.getElementsByName('mb[]')" which returns a collection (an array) of elements that can be acessed through [_number_] convention, or assign unique ID's to those elements (each element could have a NAME shared among others and a unique ID).

eg #1
document.getElementsByName('mb[]')[0] return first elemrnt with name "mb[]"

eg #2
document.getElementById("mb_01"), assuming that first element has ID="mb_01"

Hope that helps
Reply With Quote
  #4  
Old Dec 9th 2005, 7:00 pm
jimrthy jimrthy is offline
Hand of A'dal
 
Join Date: Jul 2005
Location: OK
Posts: 283
jimrthy is on a distinguished road
This is good advice, assuming you're not worried about supporting older browsers. Personally, I don't support them (unless I'm being paid ridiculously well to do so).

But you also asked about PHP.

Crap. This is what happens when I work too many hours and try to juggle too many programming languages at once. A good programmer should be fluent in many different languages. When you work in 4 of them in the same week, they sort of blur together.

If I recall correctly, PHP does basically the same thing as JavaScript.

$_POST["mb[]"] holds an array of the values that were chosen. But it seems as though you might have to do something in php.ini to enable this, as opposed to just getting the value of the last control with this name?

Never mind. Ignore me. I obviously need to just give up and get some sleep.
__________________
What do you mean I can't add a tuple to a string? That's not a tuple! Stupid computer...
Silly, but fun
Reply With Quote
  #5  
Old Dec 12th 2005, 11:38 am
dave487 dave487 is offline
Twilight Vanquisher
 
Join Date: Apr 2004
Location: Manchester
Posts: 701
dave487 is on a distinguished road
To process the form with php you need to loop through the array which is populated by your select box.

see http://www.faqts.com/knowledge_base/...aid/578/fid/61 for an example.
__________________
SEO SEO John Chow
Reply With Quote
Reply

Bookmarks

Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
mod_gzip for PHP only digitalpoint Site & Server Administration 6 Jun 14th 2009 8:58 am
Google search quits on OS X.2 w/WebSTAR5.3 mduke All Other Tools 7 Nov 11th 2008 5:00 pm
PHP Safe-Mode permissions, redux Owlcroft PHP 17 Nov 9th 2008 12:54 am
JavaScript vs. PHP links digitalpoint PHP 9 Jan 23rd 2008 1:47 am
Help Needed on Converting specific javascript commands to php such as math.random() ProductivePC PHP 4 Jun 6th 2004 3:34 am


All times are GMT -8. The time now is 2:55 am.