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?

 

 

Link to comment
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.