Current location: Hot Scripts Forums » General Web Coding » JavaScript » javascript and php clashes, need expert help


javascript and php clashes, need expert help

Reply
  #1 (permalink)  
Old 11-10-04, 08:43 PM
nassau nassau is offline
Wannabe Coder
 
Join Date: May 2004
Posts: 211
Thanks: 0
Thanked 0 Times in 0 Posts
javascript and php clashes, need expert help

i have a javascript on my page that is supposed to work tigether with a php function - but doesn't.

i need help from an expert.

i have a multi select on my page and a form that sends the items in the select to a php form page. the php form page is supposed to print ALL the items selected in the multi select, but it only prints the last item, no matter what i do.

how can i solve this?

please download the included attatchment containing the two files so u can try it out, open the "multiselect.php" file first.


thanks
Attached Files
File Type: zip multiselect.zip (2.9 KB, 154 views)
Reply With Quote
  #2 (permalink)  
Old 11-12-04, 01:31 AM
studenteye's Avatar
studenteye studenteye is offline
Newbie Coder
 
Join Date: Jul 2004
Location: UK
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
ok

You need to name your multi select list with [] after it example:

Quote:
<select name="MyList[]" size="3" multiple>
<option value="One">1</option>
<option value="Two">2</option>
<option value="Three">3</option>
</select>

Then when you submit the form to process the values that are selected...


//$_POST[MyList] will be an array containing all the values selected by the user.

Quote:
foreach( $_POST[MyList] as $val ){
mysql_query( "INSERT tbl_Temp SET Value = '$val' ");
}

Last edited by studenteye; 11-12-04 at 01:43 AM.
Reply With Quote
  #3 (permalink)  
Old 11-12-04, 07:19 AM
nassau nassau is offline
Wannabe Coder
 
Join Date: May 2004
Posts: 211
Thanks: 0
Thanked 0 Times in 0 Posts
thanks

everyone tells me i need to put [] in the select name, and i have tried it. the problem is that this causes the javascript to fail. i have also tried putting in [] in the javascript but it wasn't working.

if you, or anyone else, have a solution that works with the code i supplied in the attatchment, i'd be very happy!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
execute php into javascript function Hagoromo PHP 3 05-23-07 02:19 AM
javascript multiple select menu for php? isaacmlee JavaScript 1 10-15-04 09:53 AM
how can i use javascript in PHP sfaizanh PHP 3 01-25-04 01:31 PM
php and javascript together? gamextremer2003 PHP 5 11-06-03 02:18 PM
Javascript vs PHP, problem with arrays Chuff JavaScript 0 10-03-03 04:01 AM


All times are GMT -5. The time now is 10:35 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.