var loc_name = document.forms['create_<?php echo(htmlspecialchars($window_ID)); ?>'].elements['location_name'];
alert(loc_name);
This just gives me the message 'undefined'
where as...
var loc_name = document.forms['create_<?php echo(htmlspecialchars($window_ID)); ?>'];
alert(loc_name);
Gives me the object form business.
Have I just got this all wrong? What is the 'proper' way to access this form element. The form element has the correct name
and it has an id
, the id is similar but not the same.
HTML
<input type="button" name="create_location" value="Create" onclick="
var pre_row_was = $('#pre_form_row_1').innerHTML;
$('#pre_form_row_1').innerHTML = '<td colspan=\'3\'>Validating...</td>';
var loc_name = document.forms['create_1'].elements['location_name'];
alert(loc_name);
if(loc_name.value == '') {
alert('You can\'t leave the room name blank');
loc_name.focus(); loc_name.value = 'Enter a name';
$('#pre_form_row_1').innerHTML = pre_row_was; return false;
}
if(loc_name.value == 'Enter a name') {
alert('You must enter a room name first'); loc_name.focus();
$('#pre_form_row_1').innerHTML = pre_row_was;
return false;
}
$('#pre_form_row_1').innerHTML = pre_row_was;
Window_manager.new_window().load_xml('location/create.php?location_name=' + loc_name.value).display();">
tried formatting it so it is easier to read.