How to set the value of a hidden control??
-
Hi, I need to set the value of my hidden control. Up to this point I had just played around, have not created the full value of the hidden control. I just want to add the current local date, but that I will do. I just need to know how to set the value parameter from a value returned from a function. My hidden control: My javascript function: function GetDateTime() { var date = new Date(); // Year var year = date.getFullYear(); // Month var month = date.getMonth(); } Please can someone help me? Regards ma se
-
Hi, I need to set the value of my hidden control. Up to this point I had just played around, have not created the full value of the hidden control. I just want to add the current local date, but that I will do. I just need to know how to set the value parameter from a value returned from a function. My hidden control: My javascript function: function GetDateTime() { var date = new Date(); // Year var year = date.getFullYear(); // Month var month = date.getMonth(); } Please can someone help me? Regards ma se
-
Hi, I need to set the value of my hidden control. Up to this point I had just played around, have not created the full value of the hidden control. I just want to add the current local date, but that I will do. I just need to know how to set the value parameter from a value returned from a function. My hidden control: My javascript function: function GetDateTime() { var date = new Date(); // Year var year = date.getFullYear(); // Month var month = date.getMonth(); } Please can someone help me? Regards ma se
-
Try the following window.opener.document.forms("formname").elements("id (Example:hdnLocalDate) or name ").Value Regards, Vimal
If U Get Errors U Will Learn If U Don't Get Errors U Have Learnt
I want to set the value of the hidden control. When I do the following: Response.Write("hdnLocalDate = " + hdnLocalDate.Value); I get the value to be something like GetDateTime(). regards
-
simply add a return statement to your function, that should work no?
function GetDateTime() { var date = new Date(); return date.toString("DD/MM/YYYY"); // you can use different date formats here }
When I do a Response.Write on the hidden controls value like: Response.Write("hdnLocalDate = " + hdnLocalDate.Value); ..then it displays: hdnLocalDate = javascript:GetDateTime(); What now?? If I do a view code, must it display the value property's value as the date returned?
-
When I do a Response.Write on the hidden controls value like: Response.Write("hdnLocalDate = " + hdnLocalDate.Value); ..then it displays: hdnLocalDate = javascript:GetDateTime(); What now?? If I do a view code, must it display the value property's value as the date returned?
Hmm, good point, of course the value field will never run the javascript, just take it as a string literal....how silly of me :^) You'd have to run some function when the page loads to populate the hidden field.
window.onload = function() { hdnLocalDate.value = new Date().toString("DD/MM/YYYY"); }
Of course with runat="server" on the hidden form field its ID could easily change if its inside an INamingContainer. -
Hmm, good point, of course the value field will never run the javascript, just take it as a string literal....how silly of me :^) You'd have to run some function when the page loads to populate the hidden field.
window.onload = function() { hdnLocalDate.value = new Date().toString("DD/MM/YYYY"); }
Of course with runat="server" on the hidden form field its ID could easily change if its inside an INamingContainer.Does onload exist?? I typed in window. and then there was no onload option. I am using VS 2005. It's still not working: <!-- // Hide from old browsers window.onload = function() { hdnLocalDate.value = new Date().toString("DD/MM/YYYY"); } //-->
-
Does onload exist?? I typed in window. and then there was no onload option. I am using VS 2005. It's still not working: <!-- // Hide from old browsers window.onload = function() { hdnLocalDate.value = new Date().toString("DD/MM/YYYY"); } //-->
ma se wrote:
Does onload exist?? I typed in window. and then there was no onload option. I am using VS 2005.
Javascript intellisense in practically non-existent in visual studio, personally I use Aptana for all my JS/CSS development. My fault again that it doesn't work, using ID.attribute won't work you need a reference to the DOM element via getElementById. Try this:
<!-- // Hide from old browsers window.onload = function() { document.getElementById('<%= hdnLocalDate.ClientID %>').value = new Date().toString("DD/MM/YYYY"); } //-->
-
ma se wrote:
Does onload exist?? I typed in window. and then there was no onload option. I am using VS 2005.
Javascript intellisense in practically non-existent in visual studio, personally I use Aptana for all my JS/CSS development. My fault again that it doesn't work, using ID.attribute won't work you need a reference to the DOM element via getElementById. Try this:
<!-- // Hide from old browsers window.onload = function() { document.getElementById('<%= hdnLocalDate.ClientID %>').value = new Date().toString("DD/MM/YYYY"); } //-->
/// this is the code final, i have just test; Untitled Page <!-- // Hide from old browsers window.onload = function() { var date=new Date(); document.getElementById('<%= hdnLocalDate.ClientID %>').value = date.toDateString();//set again value if you want. //--> }