Jump to content

Recommended Posts

Hi all!

 

I'm kinda newish to Javascript, and it's not wanting to play nice with my PHP code.

 

I have a form set up like this:

<input type="text" name="startdate[]" id="startdate1">
<input type="text" name="startdate[]" id="startdate2">

The fields must have the same name because I want PHP to parse them as an array.

In javascript when I use document.getElementById('startdate1'), it always sees the name of the field, so when I try to pass a value back to it, it sends an error because it tries to assign a value to 'startdate[]'

The fields must be named as they are.. is there a way to tell javascript to use the ID, rather than the name?  ???

You can get inputfield values with javascript yes but is this really what you want? anyway here is how to get the values of your input boxes with javascript

var startdate1=getElementById('startdate1').value;

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.