Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

javascript with xsl and xml 2

Status
Not open for further replies.

YYYYUU

Programmer
Dec 13, 2002
47
GB
I am using xml to get {@id}, and xsl to display a page.

<select name=&quot;zx&quot; id=&quot;zx&quot; onchange=&quot;JAVASCRIPT:showField('zx')&quot;>

The above works in my function. The following doesn't

<select name=&quot;{@id}&quot; id=&quot;{@id}&quot; onchange=&quot;JAVASCRIPT:showField({@id})&quot;>

How can I pass {@id} in single quotations as the parameter in the showField function.

in other words. JAVASCRIPT:showField('{@id}')

Is this possible?

Fyi, function is as follows:

function showField(fred)
{
var lSelectBox = 'document.compslist.' + fred +'.value'
var lBox = eval(lSelectBox);
alert(lBox) //The idea is to show the selected value in an alert box
}
 
instead of trying to pass the string counter of that how about just passing the object to the function and then extracting the name or ID off that value

eg:
<select name=&quot;{@id}&quot; id=&quot;{@id}&quot; onChange=&quot;showField(this)&quot;>

then just a
function showField(fred) {
var myName = fred.name
var lSelectBox = 'document.compslist.' + myName+'.value'

....

___________________________________________________________________
onpnt2.gif

The answer to your ??'s may be closer then you think.
Check out Tek-Tips knowledge bank by clicking the FAQ link at the top of the page
 
Use
Code:
this
. Instead of passing the object's name/id to the function and using that name/id to conjure the object from the DOM, simply pass the object.
Code:
<select name=&quot;{@id}&quot;  id=&quot;{@id}&quot; onchange=&quot;showField(this);&quot;>
calling --

Code:
function showField(el) {
  alert(&quot;at showField, &quot;+el.id+&quot; holds &quot;+el.value);
}
 
onpnt,

Great minds think alike, and at nearly the same time. Some are just a little faster than others.
 
Thank you all for taking the time. Worked wonderfully.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top