Jump to content

[SOLVED] My java script date picker stops working when I add to variable name.


Hardwarez

Recommended Posts

I have a java script date picker. 

 

This works great:

<input type=button value="Date" onclick="displayDatePicker(\'Date\', false, \'ymd\', \'-\');">&#160&#160&#160&#160&#160<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\', \'-\');">&#160&#160&#160&#160&#160<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?

 

 

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.

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.