Reputation: 114
I've got a little problem and I'm stucking on it for a couple of days.
I downloaded a Javascript
calendar plugin (Date Input) to add a little calendar in my form.
In this form I added a button wich add another line in this form to let user set severals dates.
<input type="button" value="Ajouter" onclick="ajoutChamp('creneau')" />
I made a little script :
var s = document.createElement('script');
s.type = "text/javascript";
s.text = "DateInput('creneau_2',true,'DD-MON-YYYY')";
$("#test").append(s);
But when I'm doing this, every time I press the button I've got my calendar who appears fullscreen. It's look like the script has been executed but no appened in the html page.
Little piece of my html code :
<table id="liste_creneau" class="add_champ">
<tr id="tr_creneau_1">
<td><label for="creneau_1">creneau 1</label></td>
<td><script id="ref_date">DateInput('creneau_1', true, 'DD-MON-YYYY')</script></td>
</tr>
</table>
<div id="test">
</div>
Atm I wanted to append the calendar in a div but at the end the calendar will be in the table.
I have done other tests too but every piece of code I made ended the same way...
So maybe you could help me! :)
Edit:
Ok I made a little test
var g = document.getElementById('test');
var s = document.getElementById('ref_date');
nb++;
var clone = s.cloneNode(true);
var param = clone.firstChild.data.split('\'');
param[1] = 'creneau_'+nb;
clone.firstChild.data = param.join('\'');
g.appendChild(clone);
After that, when I click on the button, there is a script tag inserted in the div but nothing shows up. When I inspect my html page I can see it but the calendar doesn't apear...
Bye
Edouard
Upvotes: 0
Views: 1185
Reputation: 114
Well I chosen to use the jQuery-UI datepicker instead... So I guess it's solved, thanks a lot Agentminlindu and all the others :)
Upvotes: 0
Reputation: 5789
I don't understand why you are not just running the date input line. It should have the same effect.
DateInput('creneau_2',true,'DD-MON-YYYY');
Regardless, you could just try and do it all in jQuery rather than mixing javascript selectors.
$("#test").append("<script type='text/javascript'>DateInput('creneau_2',true,'DD-MON-YYYY');</script>");
Upvotes: 1