0

Please help me, here is the code in Javascript, I need to change this code to Jquery.

eval("parent.document.forms[0].strKey" + 
      intDimensionId).value = strIds[intDimensionId];
1
  • How the HTML looks like? What are you trying to do? Please give more info so we can realy help you. Anway, it's bad javascript code anyway, You should never use eval it's evil and the need of using it point you have bad code design. Commented May 31, 2012 at 6:24

2 Answers 2

1

high performance: minimal jQuery: $('form:first')[0]["strKey" + intDimensionId].value = strIds[intDimensionId];

not as high performance: full jQuery: $('form:first *[name="strKey' + intDimensionId + '"]').val(strIds[intDimensionId]);

Sign up to request clarification or add additional context in comments.

1 Comment

without jQuery at all (w/ a little help from Krister): parent.document.forms[0]["strKey" + intDimensionId].value = strIds[intDimensionId];
0

This should work although there are really plenty of ways to do this. Also note the use of the input tag. Your code may use a different tag so update accordingly.

$('input[name=strKey'+intDimensionId+']',
   parent.document.forms[0]).val(strIds[intDimensionId]);

1 Comment

yes, but the proper statement would be: 'input[name=strKey'+intDimensionId+'],select[name=strKey'+intDimensionId+']'...regardless jQuery is not required at all for this (see the comment on my post)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.