my submit button stoped working after chaigng id to id[] (1 Viewer)

tony007

Registered User.
Local time
Today, 07:02
Joined
Jun 30, 2005
Messages
53
Hi all i have problem with my java script that stoped working after chaning check box name from id to id[].

In one page i have 3 buttons. one that uses javascript to send songs to another page via url get method. One that submits check box values to next page via post .The 3th one clears the checkboxes.The problem is after changing the checkbox name Id to Id[] my other button that uses java script stoped working . . i need to keep the check box name as id[] since my other button will not work without [].I encluded the code bellow.I be happy if i get help fixing this poblem so that both buttons works.Thanks

java script code;

Code:
<script language="javascript">
<!-- hide
var checkflag = "false";
function check(field) {
if (checkflag == "false") {
for (i = 0; i < field.length; i++) {
field[i].checked = true;}
checkflag = "true";
return "Uncheck All"; }
else {
for (i = 0; i < field.length; i++) {
field[i].checked = false; }
checkflag = "false";
return "Check All"; }
}

function newWindow(url) { 
 var x,y;
 x = screen.width-35;
 y = screen.height-30;
 var win = window.open(url,'glossaryWindow','toolbar=no,directories=no,width=500,height=150'+
 'screenX=0,screenY=0,top=0,left=0,location=no,status=no,scrollbars=no,resize=yes,menubar=no');
}  

// Start of Playme Function
function playme()
{
Id = document.forms.mp3Play.Id;
tempUrl ='';
url = '';

if (Id.length > 0){  
 for (i=0; i<Id.length; ++ i)
 {
  if (Id[i].checked)
 {
  tempUrl =tempUrl +"|" + Id[i].value
  if (i == 30)
  {
   alert("Each time you can only select 30 songs to play")
   return false;
  }
 }
 }
}
else
 {
  alert("it is less than 0#2")
  tempUrl = tempUrl + "&Id=" + Id.value
 }
 //alert(tempUrl);
 url = "./mp3s/myWimpy.php?queryWhere=Id&queryValue=" + tempUrl;
 newWindow(url);
 return false;
}  
// End of Playme Function 
// --> 
</script>


checkbox page cuttons:


Code:
  <tr>
          <td colspan=7>
                            <p align="center">
                            <input type=button value="Check All" onClick="this.value=check(this.form.Id)">   
                            [B]<button id="playSelected" onclick="playme()">Play Selected</button>  [/B]                            <input type="submit" value="Add to PlayList [Members]" name="B1">  
                            </td>
        </tr>

checkbox code :

Code:
<input
                        type="checkbox" name="Id[]" value='<?=intval( $row['id'] );?>' /></td>
 

Sergeant

Someone's gotta do it
Local time
Today, 10:02
Joined
Jan 4, 2003
Messages
638
Don't you think "Id[]" is a strange name for a control?
Why do you need to name it with the "[]"?
 

tony007

Registered User.
Local time
Today, 07:02
Joined
Jun 30, 2005
Messages
53
Sergeant said:
Don't you think "Id[]" is a strange name for a control?
Why do you need to name it with the "[]"?

because one of my buttons sends check boxes value via post mthod to another page and it has to send data as array!
 

Kodo

"The Shoe"
Local time
Today, 10:02
Joined
Jan 20, 2004
Messages
707
you don't need to name it with []. That is an array syntax that is native to the language.. If I had 3 check boxes with the same ID then I would access the index of the array of check box values by doing something like this

somecontrolname[index].value

what you're doing is not necessary.
 

tony007

Registered User.
Local time
Today, 07:02
Joined
Jun 30, 2005
Messages
53
Kodo said:
you don't need to name it with []. That is an array syntax that is native to the language.. If I had 3 check boxes with the same ID then I would access the index of the array of check box values by doing something like this

somecontrolname[index].value

what you're doing is not necessary.

could u tell me how to do it my javascript? where to make changes?Thanks
 

Users who are viewing this thread

Top Bottom