Hardwarez Posted November 3, 2007 Share Posted November 3, 2007 I have a java script date picker. This works great: <input type=button value="Date" onclick="displayDatePicker(\'Date\', false, \'ymd\', \'-\');">     <input size="8" MAXLENGTH="10"name="Date" value="'.$today.'"> This is in a loop that generates a multiple froms; one long form really. Any way I am passing data with the form and because it repeats often I have to change the variables so I can access them in a whil loop later. Running a loop I am changing my vars by adding the counter number to the var name. I.E. the name set in the form is changed from date to date1 ect.. When I change the above code to this: <input type=button value="Date" onclick="displayDatePicker(\'Date\', false, \'ymd\', \'-\');">     <input size="8" MAXLENGTH="10"name="Date"'.$n.' value="'.$today.'"> It stops working!! Clicking the date button does nothing when I make that change. What am i doing wrong ??? Why does this break the script? Link to comment https://forums.phpfreaks.com/topic/75883-solved-my-java-script-date-picker-stops-working-when-i-add-to-variable-name/ Share on other sites More sharing options...
emehrkay Posted November 3, 2007 Share Posted November 3, 2007 it looks like the first parameter of the displayDatePicker() function is the name of the element where you want the return value inserted. You changed the name of the text field to "DATE . $n", so the call to the displayDatePicker() should reflect that change as well. Link to comment https://forums.phpfreaks.com/topic/75883-solved-my-java-script-date-picker-stops-working-when-i-add-to-variable-name/#findComment-384167 Share on other sites More sharing options...
mainewoods Posted November 3, 2007 Share Posted November 3, 2007 on this part of your code: "name="Date"'.$n.' value=" that double quote after: name="Date" should not be there. do it like this instead: "name="Date'.$n.'" value=" the double quote is after the single quote after the .$n. Link to comment https://forums.phpfreaks.com/topic/75883-solved-my-java-script-date-picker-stops-working-when-i-add-to-variable-name/#findComment-384324 Share on other sites More sharing options...
Hardwarez Posted November 9, 2007 Author Share Posted November 9, 2007 It was an html error. I forgot to add my counter value to the name label of the name attribute.. Link to comment https://forums.phpfreaks.com/topic/75883-solved-my-java-script-date-picker-stops-working-when-i-add-to-variable-name/#findComment-388130 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.