• Post Reply Bookmark Topic Watch Topic
  • New Topic

whats wrong in the code

 
brams mun
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi my code is like this....may be because of specifying "{", my code is not working propertly...please guide me in resolving this

here is my code :

function revertTextValue() {

alert("gamesUrl :") alert(gamesUrl${i});

var x = document.getElementById("gamesUrl${i}").defaultValue; gamesUrl${i}.value=x;

}

what might have gone wrong in specifying gamesUrl${i}, i know something is missed here....
 
Kumaravadivel Subramani
Ranch Hand
Posts: 171
Java Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
It's javascript function trying to read assign value to a DOM node right? Here without extracting the node how do you try to display the element of first occurance and try to assign value to that?

You have to extract the element object,
var obj = document.getElementById(elementId);
then try to display the object in alert,
alert("object is =+obj);

Note you have used variable 'i' without defined or initialized, also need to [] for 'n'th occurance of the same element in a single form.
 
brams mun
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, thanks for the response, the issue has been resolved by making following changes.


<td><g:textField name="gamesUrl${i}" data-default-value="${moreGamesUrls.get(country.key)}" value="${moreGamesUrls.get(country.key)}" /></td>
<td><input type="button" name="revert${i}" value="Revert" onClick="revertTextValue(gamesUrl${i})" /></td>

function revertTextValue(inp){

inp.value = inp.defaultValue;
}
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!