0
I need to adjust/adapt the calendar below. Is pure javascript
In figure 1, it is fully functional... That is, Load date from input value. Navigate between months and years and select date.
It happens that I need to use it in the bootstrap structure (4)..
Problem number one: He’s deformed... I think the main reason is because he uses a tag <table>
, <tr>
and <td>
2nd problem: I also need to work with the schedule. That is: Date + time.
So I redesigned the calendar layout using Divs... In figure 2 it is initially loading with date and time. But to add navigation features there are errors which I would like to collaborate to Save them.
1st point: Initially, comparing function calls in html I have similar parameters - they work:
Ancient:
<input type="button" name="btnData1" id="btnData1" value="." onclick="popdate('data_ini','pop1','150',document.getElementById('data_ini').value)">
Where: popdate() 1st parameter = object 2nd parameter = div 3rd parameter = size (pixel) 4th parameter = date
New:
<button class="btn btnrimary" onclick="popdataJGD('dataHoraINI','pop1',document.getElementById('dataHoraINI').value)">
Where: popdataJGD() 1st parameter = object 2nd parameter = div 3rd parameter = time date
Second point: Internally (within the function) The command to go back a month... Ancient:
...
txt += "<td width=20% align=center><a href=javascript:popdate('"+obj2+"','"+div+"','"+tam+"','"+( "01/" + (month_prior+1).toString() + "/" + year_prior.toString())+"') class='Cabecalho_Calendario' title='Mês Anterior'><</a></td>"
...
Parameters are object, div size, date... all passed with single quotes.
New:
...
txt += '<span class="control item2" title="Voltar mês">';
txt += '<a href=javascript:popdataJGD("'+ obj2 + '","'+ div +'","' + dt_prior2 +' '+ mmm +"')><</a></span>';
...
Already here (new)... If you use double quotes, on the screen in the last parameter, the encoded conversion does not consider the time as part of the value... Or, on the contrary, asks ")".
a) I deduce that I am calling the function recursively (pardon if I’m wrong)...
b) If the form of calling is almost equal... How is the last parameter interpreted: Document.getElementById('data_ini'). value ? Is string, integer or object tb ???
c) Initially calling the function by the button... Before displaying the calendar for the first time.. When "printd" in the console the parameter passed. Print as string: normal date type + space + time... Then handle separately. Passing the treated tb value to the internal parameter. That is, with the addition of space... The same conflict occurs with single quotes and double quotes. Tb tried to "escape" (/)... It didn’t work.
I appreciate any help regarding.
You quote "figures" in question but there is no figure. :/
– Sam
It’s also very confusing the question. I couldn’t quite figure out which point of the question, which problem exactly.
– Sam
I’m sorry: Basically it’s a conflict of quotation marks that I can’t explain... because in the old one it works... in the new there’s only the inversion of the quotation marks...
– JGD
Displaying the screen source after loading: <a href="javascript:popdataJGD(dataHoraINI,pop1,01/01/2019" 09:00)=""><</a> Note that date has quotes added in the code interpretation. Hence error: Uncaught Syntaxerror: Missing ")" after argument list
– JGD
The way I see it, the quotes should look like this:
txt += '<a href="javascript:popdataJGD(\''+ obj2 + '\',\''+ div +'\',\'' + dt_prior2 +' '+ mmm +'\')"><</a></span>';
– Sam
Double quotes to delimit the
href
and simple quotes escaped in the parameters. Now, by quoting the parameters, they will be sent as a string to the functionpopdataJGD
.– Sam
But you can’t use literals template?!
– LeAndrade