J'm trying to pass some data from javascript to #ENV in hidden input value, in CVT form.
In the form i have some radio inputs which are working fine and one hidden input to get the leaflet coordinates stored in js variable.
My input looks lick that:
<input value='#ENV{localisation, #GET{coord}} 'name="localisation" type="hidden"></input>
and my code:
[(#SET{coord, JSON.stringify(latlng_tab)})];
In the
console.log (#ENV{localisation, #GET{coord}})
I can see the coordinates but it doesn't work in input.
Can someone help me, please.
In case someone will be looking for an answer.
I had to remove #GET from input and #SET from the code and instead i'm using that:
<input id="localisation" value='' name="localisation" type="hidden">
</input>
var latlng_str = document.getElementById("localisation");
latlng_str.value = JSON.stringify(latlng_tab);
Related
This is my form input field (without classes and such):
<input id="input_partnerID" type="value" name="partner_id" value=""/>
I want to set the input value to the contact id of the logged in user. I can get that value with this Qweb code:
<p id="value_parterID" t-esc="user_id.partner_id.id"/>
And to get that value in my input form I use this javascript. The method is called when the "accept terms and conditions" button is clicked.
function getID() {
document.getElementById("input_partnerID").value = document.getElementById("value_parterID").innerHTML;
}
This works but probably isn't the most efficient way to do this.
How can I use Qweb to fill in the input value in 1 or 2 lines preferably without javascript?
You can set the attribute value using t-att-value="".
So in my case I should use this input field:
<input type="value" name="partner_id" t-att-value="user_id.partner_id.id"/>
Which does the same as the given example with the <p> and javascript.
I'm trying to get the value of a textbox into a JavaScript variable. ultimately I'm trying to hide or show different webparts depending on the value in the textbox. I'm piecing the code together to test for input first. Below is the code for the textbox in question that I pulled from Firebug:
<input onfocus="return (TextBox.OnFocus(this, event));" onblur="return (TextBox.OnBlur(this, event));" oninput="return (TextBox.OnInput(this, event));" id="ctl00_m_g_ff1af521_db80_4f46_9a65_42671828173f_FormControl0_V1_I1_T82" scriptclass="TextBox" class="z_VYBB68eomwymAKXW_0 c5_VYBB68eomwymAKXW_0 ef_VYBB68eomwymAKXW_0" wrapped="true" direction="ltr" viewdatanode="83" formid="ctl00_m_g_ff1af521_db80_4f46_9a65_42671828173f_FormControl0" originalid="V1_I1_T82" tabindex="0" title="" value="Visible" style="position: relative;" type="text">
If I use the code below I get an "Undefined" error message(popup). As you can clearly see though, the value of the textbox = "Visible" as the code above tells us.
$(document).ready(function()
{
var HideWeb = $("#ctl00_m_g_ff1af521_db80_4f46_9a65_42671828173f_FormControl0_V1_I1_T82").val();
alert(HideWeb);
});
I've also tried the following with no success (popup returns empty).
var HideWeb = document.getElementById("#ctl00_m_g_ff1af521_db80_4f46_9a65_42671828173f_FormControl0_V1_I1_T82").value;
alert(HideWeb);
I've also tried using the other ID numbers in hopes that one of them would work in the JavaScript\Jquery code above. If someone could pick this apart and help me determine what the problem is I would appreciate it.Thank you.
This correspondes to a question I asked here.......
https://sharepoint.stackexchange.com/questions/113969/showing-hiding-webparts-conditionally
you may try..
$("input:text[originalid='V1_I1_T82']").val()
This will return you the value..
try removing "#"
var HideWeb = $("ctl00_m_g_ff1af521_db80_4f46_9a65_42671828173f_FormControl0_V1_I1_T82").val();
I'm having problems trying to send input fields values to a Jasper report. I know how to send parameters to a report but I always did this using the show.gsp view because it was quite simple to do something like this:
<g:jasperReport controller="liquidacionDeEstano" action="crearReporte" jasper="liquidacion_estano" format="PDF" name="ReporteLiquidacion${liquidacionDeEstanoInstance.lote}">
<input type="hidden" name="LIQ_SN_ID" value="${liquidacionDeEstanoInstance.id}" />
</g:jasperReport>
Where LIQ_SN_ID is a "static" parameter used by the report.
But now I want to fill some input fields and use this values as parameters. So, what I'm doing is to use some input fields out of the jasperReport tags and hidden fields inside the jasperReport tags. Then I copy the values from the input fields to the hidden fields using JavaScript.
To generate the report I'm just using SQL and the parameters passed are used for filtering.
This is my controller closure to create the report (I think I don't need anything else but the parameters):
def crearReporte = {
chain(controller:'jasper',action:'index',params:params)
}
This is the code in the GSP form to invoke the report:
<g:jasperReport controller="reporteLotesRecepcionados" action="crearReporte" jasper="reporte_recepcion_fechas" format="PDF" name="ReportePorFechas">
<input type="hidden" id="ELEMENTO_1" name="ELEMENTO_1" />
<input type="hidden" id="ELEMENTO_CLASS_1" name="ELEMENTO_CLASS_1" />
<input type="hidden" id="FECHA_INICIAL_1" name="FECHA_INICIAL_1"/>
<input type="hidden" id="FECHA_FINAL_1" name="FECHA_FINAL_1"/>
<input type="hidden" id="ESTADO_LOTE_1" name="ESTADO_LOTE_1"/>
</g:jasperReport>
I checked that all the parameters are correct (hidden fields values) using Firebug and a Web Developer extension for Firefox but when I click the link to the report this error is produced:
Timestamp: 23/12/2013 07:20:00 p.m.
Error: TypeError: link.parentNode._format is undefined
Source File: http://localhost:8080/Liquidaciones/reporteLotesRecepcionados/create
Line: 660
Following the link to the error this automatic generated code is shown:
<script type="text/javascript">
function submit_reporterecepcionfechas(link) {
link.parentNode._format.value = link.title;
link.parentNode.submit();
return false;
}
</script>
I don't know what I'm doing wrong. In fact this is the first time I try to generate a report using values as parameters from input fields.
Please help me with this.
Thank you in advance.
I know this have been here for 11 months withuoth an answer so...
Jasper tags uses their own form and since html forbids to have nested forms:
Content model: Flow content, but with no form element descendants.
(HTML)
Jasper documentation says : "Note that the jasperReport tag should not be nested with a form element, as it uses a form element in its implementation, and nesting of forms is not allowed."
Finally I solved it but I'm not sure how I did it. Ok, here is what I did:
As you know, since Grails 2 (I think) there is a form.gsp used by the create.gsp and edit.gsp views. I was using just the create.gsp (and, in consequence, the form.gsp) view to have the input fields to obtain parameters to generate reports. Initially I located the code:
<g:jasperReport controller="reporteLotesRecepcionados" action="crearReporte" jasper="reporte_recepcion_fechas" format="PDF" name="ReportePorFechas">
<input type="hidden" id="ELEMENTO_1" name="ELEMENTO_1" />
<input type="hidden" id="ELEMENTO_CLASS_1" name="ELEMENTO_CLASS_1" />
<input type="hidden" id="FECHA_INICIAL_1" name="FECHA_INICIAL_1"/>
<input type="hidden" id="FECHA_FINAL_1" name="FECHA_FINAL_1"/>
<input type="hidden" id="ESTADO_LOTE_1" name="ESTADO_LOTE_1"/>
</g:jasperReport>
INSIDE the <g:form></g:form> tags. So, I tried, as an experiment, to copy the code to declare the input fields and the code to generate the report from form.gsp file to create.gsp, OUTSIDE the <g:form></g:form> tags (I'm not using the form.gsp file anymore). And that was all. It's working perfectly now.
As I told you I don't know how this problem has been solved. Maybe it is mandatory to have the tags outside any <g:form></g:form> tags...
...but why?
PD.: I created a domain class to have the form to enter the values that were going to be parameters. All of you must be thinking this was completely unnecessary and that having an ordinary HTML form was enough , well, I'm a Grails newbie, sorry.
I have a form with several fields populated by the user and before it is submitted some javascript gets called when a check button. It tries to set the value of the form fields to a variable that exists in the js function.
document.getElementById('var1').innerHTML = test;
alert(test);
I know the javascript is working as expected because I see the alert but the form boxes are not getting populated:
#helper.input(testForm("var1")) { (id,name,value,args) => <input type="text" name="#name" id="#id" #toHtmlArgs(args)> }
innerHTML is used to get/set the body of an html tag, so you're probably ending up with this in the html:
<input ...>test</input>
I think this may work for a <textarea>, but for your <input type="text"> you want to set the value attribute.
document.getElementById('var1').value = test;
If you want to programmatically set an html form field via JS there are many ways to do this and many libraries out there that make it really easy.
Such as various JS two-way component template binding libraries.
For instance, you can simply do the following:
HTML:
<div id="myapp">
<input id="var1"/>
<button>Submit</button>
</div>
JS:
mag.module('myapp',{
view : function(state){
var test= 'tester';
state.button= {
_onclick:function(){
state.var1=test
}
}
}
});
Here is working example of the above example:
http://jsbin.com/ciregogaso/edit?html,js,output
Hope that helps!
I've been through a lot of questions on similar issues, but can't seem to get this working. What I'm trying to do is when a button is clicked, replace the value of a form field with the word 'now' and then submit the form. Initially, the HTML form looks like this:
<tr id="row43" bgcolor="#FF0000">
<form id="form43" name="loggingUpdate" action="index.php" method="POST">
<td>PersonsName</td><td>SGS 1-26</td>
<td><input type="text" name="takeoff" id="takeoff43"/><a href='#' onclick='startTakeoff(43);return false;'><img alt='Start Now' src='brush_24.png' border='0'></a></td>
<td><input type="text" name="landing" /></td><td>0 Mins</td>
<td><input type="text" name="towHeight" /></td>
<td><input type="hidden" name="flightIndex" value="43"/><input type="submit" value="Update..." /> <a href=deleteEntry.php?flightIndex=43><img src="close_24.png" /></a></td>
</form></tr>
The Javascript that's triggered by the onclick is as shown below:
function startTakeoff(flightIndex) {
var flightForm = document.getElementById("form"+flightIndex);
var flightRow = document.getElementById("row"+flightIndex);
flightRow.cells[2].innerHTML = "<input type=\"text\" name=\"takeoff\" value=\"now\"><img alt=\"Start Now\" src=\"brush_24.png\" border=\"0\">";
flightForm.submit();
}
So when the button is clicked, it should replace the cell's value with 'now' and submit the form. The trouble is while it does submit, the changed value doesn't actually get submitted. If I manually add something to one of the other fields (the towHeight for example) and click the button, it does get submitted successfully. In other words, it is only the 'takeoff' field that doesn't get submitted when the button is clicked. I've never worked with Javascript before, so this seems very odd to me.
In the way of background, there is a PHP script that's generating the HTML and taking the submitted input, hence some of the strange IDs. The entire page can be seen here in case I've left anything out http://ad7zj.net/logging/index.php I'd appreciate the help!
You are looking for the .onsubmit() event.
That said, you might be best off just getting the time from the server. It will save you from a whole world of time zones, day light savings time issues, and the number of computers out there with inaccurate time settings.
EDIT:
Ok, thanks to your comment I think I see what is going on.
You are trying to update the form using .innerHTML. .innerHTML is a rather strange beast and full of all sorts of heartache -- yield not to its temptations. It looks like the browser is waiting till the Javascript event is over before actually applying the innerHTML update. That would be my guess, anyways. Outside of the simplest of updates, I avoid the thing.
Nuke this:
flightRow.cells[2].innerHTML = "<input type=\"text\" name=\"takeoff\" value=\"now\"><img alt=\"Start Now\" src=\"brush_24.png\" border=\"0\">";
Try this instead:
// Assuming only one form with one name 'takeoff'
var el = document.getElementsByName("takeoff")[0];
el.value = 'now';
// The rest of the updates shouldn't matter -- the form is being submitted, nothing should be seen.