Link to home
Start Free TrialLog in
Avatar of MJ
MJFlag for United States of America

asked on

Eval variables in function call

I need to be able to set  the value of the variable in the string being passed. I can't break up the one parameter:

contentmediatype=content_type_media,contentcategory=classification_category,contentbucket=classification_subcategory,contenttitle=content_type_title


because it can be any number of assignments. The obvious issue is that I split out and eval the assignments but currently i don't get the values assigned to  content_type_media, classification_category etc. because it just makes the values "content_type_media" not the actual value (value1)!  How can I do this?

content_type_media = value1;
classification_category = value2;
                                        ...etc.
      setOmniValues('','','','contentmediatype=content_type_media,contentcategory=classification_category,contentbucket=classification_subcategory,contenttitle=content_type_title','', '', 1)
      
Avatar of Zvonko
Zvonko
Flag of North Macedonia image

I do not see your problem.
Compare to this:

<script>

content_type_media = 'value1';
classification_category = 'value2';
classification_subcategory = 'value3';
content_type_title ='value4';
                                     
     setOmniValues('','','','contentmediatype=content_type_media,contentcategory=classification_category,contentbucket=classification_subcategory,contenttitle=content_type_title','', '', 1)

function setOmniValues(a,b,c, theStatement){
  alert(theStatement);
  eval(theStatement);
  alert(contenttitle);

}
</script>

ASKER CERTIFIED SOLUTION
Avatar of third
third
Flag of Philippines image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial