views:

27

answers:

2

send a value from javascript to html form input having a value in javascript, need to send that to <'input type='hidden' id='imgscr'/> when submitting the form the value also should submit.. (set value from javascript to html form input)

A: 

Your question is not very clear, but I think the answer is

document.getElementById('imgsrc').value = js_variable;

You might want to put this function in the forms onsubmit handler.

Pepijn
A: 

If you use jQuery, this is as easy as:

<form onsubmit="$('#imgscr').val('some value')">

You can substitute whatever you want for the value.

It is also possible to use the form notation if you set a name on your input field:

<form onsubmit="this.imgsrc.value='some value'">
  <input type="hidden" name="imgsrc" id="imgsrc">
</form>
tadman