33 lines
1017 B
Plaintext
33 lines
1017 B
Plaintext
1) Copy and Past at the top of the body :
|
|
<script>
|
|
function setInputVal(id, value) {
|
|
let input = document.getElementById(id);
|
|
input.value = value;
|
|
}
|
|
</script>
|
|
|
|
2) Call the function inside onclick event :
|
|
<img
|
|
src="../images/scarpa.jpg"
|
|
width="612"
|
|
height="334"
|
|
border="0"
|
|
onclick="setInputVal('descriptionpartvalue', 'toebox')"
|
|
href="javascript:void(0)"
|
|
usemap="#map"
|
|
/>
|
|
|
|
setInputVal function receives 2 arguments:
|
|
i ) id
|
|
ii) value
|
|
|
|
`id` means id attribute of that input tag whose value you want to change.
|
|
if <input id="abc" name="xyz"/> is an input, then `abc` will be it's id
|
|
|
|
`value` means which value you want to set in that input field.
|
|
if you want to set `toe` as value of that input, then you've to
|
|
pass `toe` as second argument
|
|
|
|
3) After `onclick` attribute you must replace `href` with `href="javascript:void(0)"` otherwise your
|
|
page will be reloaded!
|