1
Well, when clicking on the "Program News" button appears an input to by date and time... But when sending the "form", the input that is inside the javascript is not receiving the data, the normal ones are already... Funny that I used this code yesterday and it was working
} elseif($do == "add"){
$editor_mode = true;
if($_POST['submit']){
if($_POST['postdate']){
$status = "Inativo";
$programada = "sim";
}else{
$status = $_POST['status'];
$programada = "não";
}
mysql_query("INSERT INTO cms_news (title,image,longstory,shortstory,published,author,promo,categoria,status,postdate,posthora,programada) VALUES ('".$_POST['title']."','".$_POST['image']."','".$_POST['longstory']."','".$_POST['shortstory']."','".time()."','".$_POST['author']."','".$_POST['promo']."','".$_POST['categoria']."','".$status."','".$_POST['postdate']."','".$_POST['posthora']."','".$programada."')") or die(mysql_error());
mysql_query("INSERT INTO stafflogs (action,message,note,userid,targetid,timestamp) VALUES ('Notícias','Publicou uma notícia','news.php','".$my_id."','".$key."','".$date_full."')") or die(mysql_error());
echo "<script>alert('Registro inserido com sucesso')</script>";
$editor_mode = false;
}
}
?>
<fieldset><legend><?php echo $pagename; ?></legend>
<table width="100%" style="float:right;border:0px">
<form action='<?php echo $adminpath; ?>/index/p/news&do=add' method='post' name='theAdminForm' id='theAdminForm'>
<tr>
<div class="input_field">
<div style="margin-left:69px;">
<label for="num"><b>Titulo</b>:</label>
<input required="required" type="text" name="title" class="bigfield">
</div>
</div>
</tr>
<tr>
<div class="input_field">
<div style="margin-left:69px;">
<label for="num"><b>Resumo</b>:</label>
<input required="required" type="text" name="shortstory" class="bigfield">
</div>
</div>
</tr>
<tr>
<div class="input_field">
<div style="margin-left:69px;">
<label for="num"><b>Top Story</b>:</label>
<input required="required" type="text" name="image" class="bigfield"><div style="margin-left:29px;"><i>Utilizar o link da imagem, preferêncialmente do Imgur. Não é permitido dos servidores da Sulake.</i><div>
</div>
</div>
</tr>
<tr>
<div class="input_field">
<div style="margin-left:69px;">
<label for="num"><b>Autor</b>:</label>
<input required="required" type="text" name="author" class="bigfield">
</div>
</div>
</tr>
<tr>
<div class="input_field">
<div style="margin-left:69px;">
<label for="num"><b>Categoria</b>:</label>
<select required="required" name="categoria" style="margin-top:05px;">
<option value="" id="categoria">Selecione</option>
<?php
$sql = "SELECT * FROM cms_news_cat ORDER BY ID";
$query1 = mysql_query ($sql) or die (mysql_error());
while ($manu = mysql_fetch_array ($query1)){
?>
<option value="<?php echo $manu['id']; ?>"><?php echo $manu['nome']; ?></option><?php } ?></select>
<div style="margin-top:5px;"></div>
</div>
</tr>
<tr>
<div class="input_field">
<div style="margin-left:69px">
<label for="num"><b>Tipo</b>:</label>
<select required="required" name="promo" style="margin-top:05px;">
<option value="" id="tipo">Selecione</option>
<option value="Sem Promoção">Não especificar</option><option value="Promoção Aberta">Promoção Aberta</option><option value="Promoção Encerrada">Promoção Encerrada</option></select>
<div style="margin-top:5px;"></div>
</div>
</tr>
<tr>
<div class="input_field">
<div style="margin-left:69px;">
<label for="num"><b>Status</b>:</label>
<select required="required" name="status" style="margin-top:05px;">
<option value="" id="tipo">Selecione</option>
<option value="Ativo">Ativo</option><option value="Rascunho">Rascunho</option><option value="Inativo">Inativo</option></select>
<div style="margin-top:5px;"></div>
</div>
</tr>
<div id="inputprogram"></div>
<script type="text/javascript">
function insereInput() {
if ( document.getElementById('botao').innerHTML == 'Programar Notícia' ) {
// modificar texto do botão:
document.getElementById('botao').innerHTML = 'Não Programar Notícia';
// ou se usares <input type="button"> em vez do elemento <button> simplesmente muda innerHTML para value
document.getElementById('inputprogram').innerHTML = '<tr> <div class="input_field"><div style="margin-left:69px;"><label for="textfild"><b>Postar em</b>:</label><input required="required" type="text" name="postdate" class="smallfield"> <input required="required" type="text" name="posthora" size="03"><div style="margin-left:115px;"><i> Dia/Mês/Ano Hora:Minuto</i></div></div></div> </tr>';
} else {
// modificar texto do botão de volta para o padrão:
document.getElementById('botao').innerHTML = 'Programar Notícia';
document.getElementById('inputprogram').innerHTML = '';
}
document.querySelector("form").submit();
}
</script>
<tr>
<div class="input_field">
<div style="margin-left:69px;">
<label for="num"><b>Notícia</b>:</label>
</div>
<br><br><textarea name="longstory" id="story" class="ckeditor"></textarea></td>
</div>
</tr>
<input class="submit" type="submit" name="submit" value="Inserir Registro" />
<button class="submit" type="button" id="botao" onclick="insereInput()">Programar Notícia</button>
</form>
</table>
</fieldset>
It didn’t work, the data of the field that is in javascript is coming in blank in the POST
– user89739
He takes all fields, only the field that is in javascript he does not take, I do not understand this...
– user89739
@Carlosg I see here for you..
– Sam
@Carlosg I updated the answer with an Edit. Make the changes and test there.
– Sam
Man, you are awesome... 4 hours of head-breaking here, why before this code worked, I must have ended up trading these deals, solved here, I could never imagine that the table would interfere, thank you!
– user89739