August 13, 201313 yr Hi all. Ok I'm not too good with forms and have been asked to look at one on a Wordpress site. This is what I have: <form id="top-search-form" method="POST" action=""> <input type="hidden" id="Submit" name="Submit" value="" /> <input type="hidden" id="CountryChoice" name="CountryChoice" value="Ireland" /> <input type="hidden" id="Currency" name="Currency" value="EUR" /> <input type="hidden" id="selDay" name="selDay" value='' /> <input type="hidden" id="selMonth" name="selMonth" value='' /> <input type="hidden" id="selYear" name="selYear" value='' /> <input type="hidden" id="SubmitButton" name="SubmitButton" value='search' /> <label>Date:</label> <input type="text" id="main_datepicker" size="15" value='<?= date("d/m/Y") ?>' /> <label>Nights:</label> <select name='NumNights'> <option>1</option> <option>2</option> <option>3</option> <option>4</option> <option>5</option> <option>6</option> <option>7</option> <option>8</option> <option>9</option> <option>10</option> <option>11</option> <option>12</option> <option>13</option> <option>14</option> </select> <label for="Choice">City:</label> <select id='Choice' name="Choice" class='form city_choice'> <option value='H112'>Dublin</option> <option value='H402'>Galway</option> </select> <input type="submit" value=""> </form> Now what I don't understand is how this form is being submitted to a page on a different site with the populated fields. But there is also an issue here, the date and number of nights are not being pulled through, only the City... As I said I'm not great with forms, and I know it's tough to find a solution with the code above, but can anyone give me any ideas what I should be looking for? I don't see any JS or PHP files related to the form on the server. Edited August 13, 201313 yr by mrludable
August 13, 201313 yr The only thing I can think of is an external JS function that's maybe manipulating the form elements! Otherwise, I don't see how the values can be retrieved without value attributes.
August 13, 201313 yr Author Thanks for the reply Lyndsey. I did find this file after a bit of searching: jQuery(function($) { if (typeof($().watermark) != "undefined") { $('#newsletter-signup input.wpcf7-text[type=text]').attr('placeholder', 'Just Enter your Email'); $('input[placeholder],textarea[placeholder]').watermark(); } $(".datepicker").datepicker({ showOn: "both", buttonImage: "/img/form-date-icon-grey.png", buttonImageOnly: true, dateFormat: "dd/mm/yy" }); $("#main_datepicker").datepicker({ showOn: "both", buttonImage: "/img/form-date-icon-green.png", buttonImageOnly: true, dateFormat: "dd/mm/yy" }); $("#top-search-form").submit(function() { var date_str = $('#main_datepicker').val(); var date_parts = date_str.split('/'); day = (date_parts[0].length == 1 ? '0'+date_parts[0] : date_parts[0]); month = (date_parts[1].length == 1 ? '0'+date_parts[1] : date_parts[1]); year = date_parts[2]; $('#selDay').val(day); $('#selMonth').val(month); $('#selYear').val(year); current_city_val = $('#Choice').val(); current_action = $('#top-search-form').attr('action'); if (current_city_val == 'H112') { // dublin new_action = 'http://www......'; } else { new_action = 'http://www......'; } $('#top-search-form').attr('action', new_action); }); }); I'm also not too good with Javascript / jQuery - do you think there is something wrong in this file that's not pulling in the date or number of nights?
August 13, 201313 yr Well the date parts (day,month,year) are being split up and placed in to the hidden form fields (#selDay, #selMonth, #selYear) based on the selection on the datepicker (#main_datepicker). Regarding NumNights, that's not being referenced anywhere so shouldn't be returning anything as the options have no value attributes (that are referenced server side)... e.g. <option value="this will be sent via POST variable"> Option 1 </option>
August 13, 201313 yr Author Thanks again Lyndsey. I had noticed that the NumNights weren't being referenced in the .js file, but I was wondering if there was something wrong within the js code that was causing the date not to get pulled through. I'll keep looking and see if I can get it sorted... All a bit of mess to me tbh.
August 13, 201313 yr I'd just double check the error console to see if there's any JS errors being brought back. Otherwise, it looks OK.
August 13, 201313 yr agree with Lyndsey use the console in Chrome/Firefox to see if there are any issues. As you say this is pulling the Choice variable but there is no call for the NumNights so I would add this into the code
Create an account or sign in to comment