jamina1 Posted June 25, 2007 Share Posted June 25, 2007 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? ??? Link to comment https://forums.phpfreaks.com/topic/57071-javascript-form-field-with-same-name-for-php/ Share on other sites More sharing options...
RichardRotterdam Posted June 27, 2007 Share Posted June 27, 2007 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; Link to comment https://forums.phpfreaks.com/topic/57071-javascript-form-field-with-same-name-for-php/#findComment-284074 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.