Targetting elements via javascript... how?

The following is code for a navigation menu where only one option appears lit at a time (based on code sent to me by the amazing Jon Fritz II).
CSS:
a#button0, a#button1 {
    display:block;
    float:left;
    width:55px;
    height:67px;
    margin:0;
a#button0.inactive
{ background:url(/carousel_home.png) -55 0 no-repeat }
a#button0.active
{ background:url(/carousel_home.png) 0 0 no-repeat }
a#button1.inactive
{ background:url(/carousel_vip.png) -55px 0 no-repeat }
a#button1.active
{ background:url(/carousel_vip.png) 0 0 no-repeat }
HTML:
<a href="#" onclick="changeClass(this)" class="inactive menu" id="button0"> </a>
<a href="#" onclick="changeClass(this)" class="inactive menu" id="button1"> </a>
JSCRIPT:
<script>
function changeClass(elClass) {
  var divsLength =  document.getElementsByClassName("menu").length;
  for (i = 0; i < divsLength; i++) {
    document.getElementsByClassName("menu")[i].className = "inactive menu";
  elClass.className = "active menu"; 
</script>
What this does is swap the class of a clicked button (in a menu) while reverting all the other buttons back to their original state, so only 1 button appears "lit" at a time. The A tags are used as block elements that simply shift the background image so as to produce a "lit" and "unlit" state.
My question is... via javascript (or anything else), is it possible to trigger class changes for the buttons from an area OUTSIDE the menu? In other words, can we make a text link on the page itself trigger which button in the menu to "light up". Something like <a href="javascript:slide('div1'); javascript:(go light up button1)">Example</a>
The reason is that this menu is not the ONLY way to get from one section to another. So if I click on a link in another DIV on the same page that takes me to another area, ideally, I'd like to see the button representing that area in the nav menu light up like it's been clicked on -- even if it hasn't. And of course, the other buttons would NOT be lit.
Thanks!

I hadn't even noticed you changed the name of the function from changeClass to setClass, which of course who immediately explain why it started working on those elements that were still calling changeClass... except that when I changed the individual calls to setClass, they still wouldn't work.
Was I supposed to leave the former changeClass function in the javascript? Is your setClass function supposed to be used in conjuction with the other one? Because I replaced one with the other, and ever since then, the new behavior works but the old one (clicking directly on the icon) does not.
Here is my menu :
<a href="javascript:slide('div-home')" onclick="setClass(this)" class="inactive menu" id="button0"> </a>
<a href="javascript:slide('div-vip1')" onclick="setClass(this)" class="inactive menu" id="button1"> </a>
<a href="javascript:slide('div-vip2')" onclick="setClass(this)" class="inactive menu" id="button2"> </a>
<a href="javascript:slide('div-vip4')" onclick="setClass(this)" class="inactive menu" id="button4"> </a>
<a href="javascript:slide('div-vip5')" onclick="setClass(this)" class="inactive menu" id="button5"> </a>
<a href="javascript:slide('div-done')" onclick="setClass(this)" class="inactive menu" id="button6"> </a>

Similar Messages

  • Controlling Browser Elements via JavaScript or ActionScript

    From within one Flash movie, I'd like to open another browser
    window containing a different Flash movie. The movie opens just
    fine, but I'd like to deactivate the menu bar, address bar, and
    toolbar.
    Questions:
    • Can I control/set these elements?
    • Should this be done with AS? With JavaScript?
    • I've heard that using JS to perform such a task is
    problematic in some browsers?
    Any help shedding light on these questions is greatly
    appreciated.
    Octothorpe

    I would suggest getting yourself a javascript primer if
    you're going to do any sort of web programming. I've found some
    free tutorials hosted by
    http://www.w3schools.com/
    really helps. Second, it looks like Dave's script is using a
    javascript function that's he's added to the page, it's not part of
    the standard javascript library. The real javascript command is
    window.open(params). There are many many examples on the web of how
    to do this given the right search. Just be aware that it's real
    easy to get confused on the quotes and parentheses required for any
    getURL command that calls javascript.

  • How to get elements in a multi-value field via javascript?

    The following will set variables.variable1 to variables.variable2 when the "Script Link" component is clicked...
    <Field>
    <Display class='Javascript'>
    <String>
    function myScript() {
    el=getElement(document.mainform,"variables.variable1");
    el2=getElement(document.mainform,"variables.variable2");
    el.value=el2.value;
    </String>
    </Display>
    </Field>
    <Field name='Script Link'>
    <Display class='Link'>
    <Property name='URL'>
    <String>javascript:myScript();submitCommand(document.mainform,%20'Recalculate');</String>
    </Property>
    </Display>
    </Field>
    My issue is, if variables.variabl2 is a list / multivalued, i get errors trying to traverse through the "array".
    How can i read and set an a list element via javascript function above? I've tried things like get() , and variables.variable2[0] .
    any help would be appreciated....
    is there an API somewhere i can reference?

    Hi,
    thanks for your reply!
    If I have the parameters in the URL and use the method GET it works all right.
    but I need the method to be POST. I suppose, I have the wrong way identifying the parameter name
    This is from VB
    varTarget = "http://localhost:9090/gm/getData" ' getData is my servlet
    xmlSendStr = "SQLStmt=SELECT TCPD_Cars.* From TCPD_Cars WHERE (((TCPD_Cars.CarIdent)=45));"
        xmlHttp.Open "POST", varTarget, True   'True means asynchronous
        xmlHttp.Send xmlSendStrthis is part of my Servlet
         protected void doPost(HttpServletRequest request, HttpServletResponse response)
                   throws ServletException, IOException {
              response.setContentType("text/html");
              PrintWriter writer  = response.getWriter();
              String SQLStmt = request.getParameter("SQLStmt") ;
            //make the database query and get the returns
            writer.println(GetSQLData(SQLStmt));
            //close the write
            writer.close();                    
         }I would appreciate any suggestions

  • Resize an Object via javascript

    Resize an Object via javascript
    How do I...
    I want to select an object in my document, onscreen, (an image, or text) then run a script that will discern the object selected, and show a dialog box that will allow me to input a sizing percentage for that object (with anchor corner/center)(Press enter and object resizes).

    No they don't.
    Acrobat may be bundled with Creative Suite collections but the APIs has nothing in common other than the use of JavaScript. CS apps use the ExtendScript system, Acrobat has its own internal API and an SDK for inter-application control.
    PDF is an end-destination format - the page content is not designed to be edited, so while there are tools in the user interface to allow touchups and corrections to page objects those features are not available for automation. The JavaScript engine does not have access to the low-level document structure, it can only see markup (comments and form elements) and a limited range of document properties.
    bdmasha wrote:
    They are all part of a suite of tools that share a common access to internal api's via scripting/programming languages.
    InDesign is not Photoshop is not Illustrator, but they have much in common when accessing their api's that Acrobat does not allow--and Acrobat is part of that Adobe suite.
    Thanks again.

  • Sun IdM: How to set a multi-value field on document.mainform via javascript

    The following will set variables.variable1 to variables.variable2 when the "Script Link" component is clicked. I would like to modify
    this so that el2 references a multi-valued element (e.g. a list generated by a Select Field)
    <Field>
    <Display class='Javascript'>
    <String>
    function myScript() {
    el=getElement(document.mainform,"variables.variable1");
    el2=getElement(document.mainform,"variables.variable2");
    el.value=el2.value;
    </String>
    </Display>
    </Field>
    <Field name='Script Link'>
    <Display class='Link'>
    <Property name='URL'>
    <String>javascript:myScript();submitCommand(document.mainform,%20'Recalculate');</String>
    </Property>
    </Display>
    </Field>
    My issue is, if variables.variable2 is a list / multivalued, i get errors trying to traverse through the "array".
    How can i read and set a list element via the javascript function above? I've tried things like get(), put() , as well
    as path expressions like variables.variable2[0] .
    any help would be appreciated....
    is there an API somewhere i can reference?

    The MultiSelect field-type is a little different than the rest of the fields. If you use the applet version, then selecting/deselecting values cannot be captured by referencing the field directly in javascript.
    The way to identify the selections is to use the javascript methods includes/MultiSelect.js file (IDM form submission uses the same method):
    fixMultiSelectAppletBeforeSubmit( )
    fixMultiSelectNonAppletBeforeSubmit( )
    .. and then referencing the "<multiselect-field>_selected" form element.
    So in your case, the code should look something like this:
    function myScript() {
        fixMultiSelectAppletBeforeSubmit(document.mainform,"variables.variable1");
        var el1 = getElement(document.mainform,"variables.variable1_selected");
        // assign the value to variable2..
        el2 = getElement(document.mainform,"variables.variable2");
        el2.value = el1.value;
    }Just make sure ":variables.variable2" is not a multi-select field, else the value set here will be reset during form submission.
    Adi
    [www.xpressutils.com|http://www.xpressutils.com]

  • How to include HTML file in JSP using HTML elements or Javascript?

    Hi,
    I have around 15000 static html files one for each item which we display each upon invoking an item.The HTML file should be part of a JSP file.
    Please note that the name of the HTML file is determined dynamically
    Placing all the HTML files within the web application does not give us good performance so i would like to put all of them in the webserver.
    I am not able to include the file in the JSP using the jsp:include attribute if i place the HTML files in the webserver ,
    in order to do that i think should use either HTML element or javascript to include the HTML in the JSP.is there any alternative to <Jsp:include>
    Does anyone have an idea how to include the HTML file and take advan tage of webserver?
    Any ideas are appreciated

    What you need to do is simply read the HTML file from the disk and dump it out to the outputstream. It really is that simple.
    There's no reason you need to include all 15000 files in the actual WAR, you can place those files any place handy that is easy for the application to see (in another directory, or accessible from a file server if you have multiple front ends).
    Then, just write a utiility function that takes the output stream (i.e. the 'out' JSP variable), and the file name, read the file, and write it to the stream.
    If you start noticing performance issues, then you can try doing some caching, but truth is your OS should be doing that for you.
    But, truth be told that's the only practical way to do it.
    Another solution would be to use JavaScriipt and XMLHttpRequest (i.e "AJAX") to load the file at the client side, and simply replace a tag with the results.
    That's also pretty trivial to write, any web site talking about AJAX should give you hint there.
    Of course, that won't work for folks who have JavaScript turned off, or some other incompatible browser, whereas the server side solution obviously works everywhere.

  • How to get Parent Symbol name of current e.target element ?

    How can I get the Parent Symbol name of the current e.target element ?
    would that involve using this ?
    getParentSymbol()
    Thanks for the help

    Hi ,
    I created a composition where I am trying to access the parent symbol of a rectangle. The structure is like this -
    Stage->parentMainSymbol->ChildSymbol->childRectangle. Now for the parentMainSymbol click , to access the rectangle element(which is the target) you can use the following snippet -
    sym.getComposition().getStage().getSymbol("parentMainSymbol").getSymbol("ChildSymbol").$(" childRectangle")
    Now, the parent of this is ChildSymbol whose reference could be obtained by -
    sym.getComposition().getStage().getSymbol("parentMainSymbol").getSymbol("ChildSymbol").$(" childRectangle")[0].offsetParent
    The info about the parent symbol is just being printed in the console view for the attached composition. This would print it out for -
    #Stage_parentMainSymbol_childSymbol which is the parent symbol of the target childRectangle under consideration.
    Kindly, take a look and let me know if it solves your problem.
    Thanks and Regards,
    Sudeshna Sarkar

  • I used firefox 3.6.14 on windows 7 x64 (firxfox x32). I found a problem when I develop my website and alert data or value via javascript , firefox hang (not response) every time. What's happend? How to solve is problem?

    I used firefox 3.6.14 on windows 7 x64 (firxfox x32). I found a problem when I develop my website and alert data or value via javascript , firefox hang (not response) every time. What's happend? How to solve is problem?
    Thank you for help
    Lohkaeo

    Oops - for some reason, this problem now seems to have gone away. May have had something to do with Flash. I'll keep my fingers crossed.

  • How did i solve "Cannot create target element" but still having problems.

    Hi Experts,
    I solved my problem of "Cannot create target element" by removing of the data type structure the following fields :
    DT_AS400_1 -> Complex Type
    Payroll      1..1   (Should i put 0..0?)
       ->  Row  0..Unbounded And then Fields to be passed.
    I can't figure how pi can't detect the fields, i use them pretty often.
    Any Suggestions,
    Thanks for your help,
    Regards,
    Steve.

    Hi Steve,
    Check if input message, has the field that is producing the output.
    Therefore, if you don't have any input to fill the structure root, you can fill it with an empty constant.
    Best regards,
    Pedro M. D. Pereira
    Edited by: Pedro Pereira on Jun 10, 2010 1:26 AM

  • How can I add a watermark via JavaScript that includes the current datestamp?

    Part of my daily work process here is to scan in a huge stack of inbound mail. I then OCR the scans, delete the blank pages, and add a watermark. I've got a batch process set up for the first two steps, but I can't make a watermark for the datestamp itself and need to do so via JavaScript, but I have a luddite-level understanding of it.
    As of right now, these are my settings I'm using to add the datestamp:
    What I want to do is run a script to do the same thing and insert the current date where I have mm-dd-yy currently, but I don't have the first clue of where to start. Any help you could offer would be hugely appreciated

    You can use the doc.addWatermarkFromText() method as a JavaScript step in an Action.
    for example
    var dt = new Date();
    var stoday = (dt.getMonth() + 1) + '-' + dt.getDate() + '-' + dt.getFullYear();
    this.addWatermarkFromText({
    cText: "Deposit\r" + stoday,
    nTextAlign: app.constants.align.right,
    nHorizAlign: app.constants.align.right,
    nVertAlign: app.constants.align.top,
    nHorizValue: -72, nVertValue: -72
    See the SDK Help files for information on what all the parameters do.

  • Uploading a File with AppleScript via JavaScript

    Hi everybody,
    being new to AppleScripting and JavaScripting I'm faced with the following problem:
    Is it possible to make AppleScript to input the path for a file to be uploaded via JavaScript? If yes, what should be the correct Path Format and how to wrap it up the JavaScript action into AppleScript? I've tried a few comands but to no success.
    On the webpage in question, there's a "Choose" button, that is defined as follows:
    <input type=​"file" class=​"gwt-FileUpload" name=​"swfFile">​
    I've been trying to use the following syntax:
    do JavaScript "document.getElementsByName('swfFile')[0].value('Macintosh HD:Users:myaccount:Desktop:Scrapbook:!动画.swf')" in document 1
    as well as this one, where the Path is definitelly understood by shellscript:
    do JavaScript "document.getElementsByName('swfFile')[0].value('/Users/myaccount/Desktop/Scrap book/!动画.swf')" in document 1
    The name of the file is (and must remain) in chinese, but for testing purposes I have also tried files with english names, without success.
    Currently I'm using a solution with JavaScript comand:
    do JavaScript "document.getElementsByName('swfFile')[0].click()" in document 1
    to click the finder  window to browse for the file, and manipulating  keystrokes by using System Events to find the right file, but it's not  infallible with a number of files and it's hardly an ellegant sollution.
    Any idea what I'm doing wrong?
    Cheers!

    @twtwtw
    the do JavaScript "document.forms[0].submit()" command didn't work, so I kept the original way of submitting by clicking the button. The submitting part works, but not the input file part.
    That's the code I used
        tell application "Safari"
            do JavaScript "document.getElementById('gwt-uid-13').value='on'" in document 1
            do JavaScript "document.forms[0].elements['swfFile'].value=" & "'" & SWFFilePath & "'" in document 1
            do JavaScript "document.getElementsByClassName('gwt-SubmitButton')[0].click()" in document 1  
            delay 1
        end tell
    with SWFFilePath set as the POSIX path as well as the default file format
    Macintosh HD:Users:myaccount:Desktop:Scrapbook:!动画.swf'
    but it did not work.
    If you've got the time, feel free to upload an .swf. The service is free and the server delats uploaded files after 15 min. (if you don't have any, you may try an empty .txt file instead - it won't get converted, but the point is just to get it into the input box).
    In the meantime, I'll have a look at adayzdone's suggestion. It's not perfect (the downside being that it requires the window to be active, so I can't run the script in the background or with my screensaver & password on), but it's still more reliable than my sollution with navigating arrowkeyes.

  • Mapping error: cannot produce target element

    Hello all,
    I am trying to test a mapping. i have 3 messages in my source and one Msg in my target. when i test execute it
    i get this msg:
    1) compilation of mapping successful
    2) cannot produce target elements/Check xml instance is valid for source xsd and target-field mapping fulfills requirements of target xsd.
    I am not sure what the error might be, can somebody please advice..
    Thanks in advance

    Hi Harika,
    how many Elements do u have In your Source Message Type(for example you have 3 elements and how u want to see these elements in your Target Message Type, define that much elements in your Target Message Type and Mappe those)
    1. usually people will go with one to one element mappaing, in such case define your souce and Target Message type Elements equal
    other wise you can do one Source having 3 elements and you want to see only one output from them then use Standard Function like "Contacte" that will add the 3 elements in one.
    if you are satisfied with this please provide points to me.
    Ashok

  • Unable to create Target Element error

    Hi Experts,
    I have Source and taget messages as below:
    Target Structure
    MT_Table----
                1:1
    Row--
    0..unbound
    -Field1--
    1.1
    -Field2--
    1.1
    -Field3--
    1.1
    -Field4--
    1.1
    Source is IDOC
    ZMaterial----
    1.1
    IDOC--
    1.1
    -Begin--
    Req
    ---EDIDC40
    Segement---1.1
    Table----
    1.1
    -E1MARAM-1.999
    -SEGMENNT--0..999
    Field1-------0..1
    Field2-------0..1
    I will have multiple IDOCs where I need to generate Multiple rows in a file:
    I am getting an error as below:
    Start of test
    Cannot create target element /ns0:MT_Table/Row[2]/Field1. Values missing in queue context. Target XSD requires a value for this element, but the target-field mapping does not create one. Check whether the XML instance is valid for the source XSD, and whether the target-field mapping fulfils the requirement of the target XSD
    I have a condition if SEGMENT-Field1 equals A then substring of SEGMENT-Field2 (first 16 characters).
    Many Thanks
    Rajeev

    I see the Source Message is as below:
    <?xml version="1.0" encoding="UTF-8" ?>
    <ZMaterial>
    +<IDOC BEGIN = "1">
    +<IDOC BEGIN = "1">
    +<IDOC BEGIN = "1">
    </ZMaterial>
    Dont know how to get multiple rows in a file with multiple IDOCs.
    Any Light please?
    Thanks
    Rajeev

  • ERROR IDoc2File "Cannot produce target element"

    Hi,
    well i am sending an IDoc as i did some times before via XI to the client.
    Funny thing is that now it's the first time the MM is not able to handle empty fields from sender.
    I configured the target DT and the field 'co' from IDoc for occurrence with 0..1 but when i test the MM with the given XML-Structure from SXMB_MONI i am getting following ERROR:
    <b>Cannot produce target element /ns0:MT_Certificate/recordType2A/co. Check xml instance is valid for source xsd and target-field mapping fulfills requirements of target xsd</b>
    This field is the first one which is empty in the sent IDoc - but i have no clue why the is a problem because i did this some times before and it all works and i havn't done anything wrong - i hope.
    So do u have an idea?!
    br, Jens

    Jese,
    I explained it above, but let me try to put it better.
    MAPWITHDEFAULT is used to check if a the source field exists. if it exists then it maps the source with the field else it maps the default value to the target field.
    When a field is not populated by an idoc, the field is not a part of your XML strucuture itself. In your mapping, the field for which you have used MAPWITHDEFAULT I guess has a occurence of 1..1 and so, as the source field does not come in the Idoc, the mapping fails and this is now handled with mapwithdefault.
    Hope this helps,
    Regards
    Bhavesh

  • Target element missing in application mapping

    Dear Experts,
                                               (Request)
    I am working on SOAP <> SAP-XI <> SAP ECC ( Proxy).
                                               (Response)
    Since the Request and Response message types are same , I have created 2 Message Type i.e. 1 for Request and 1 for
    Response.
    Part1:
    So for Service Interface , I am using the same message types for SOAP and SAP.
    Note: I have used all the data types,message types, message mapping and operation mapping under 1 namespace.
    2 Message Mapping are working fine.Is this design fine?
    Part2:
    When tested with SOAP Test tool, I am getting error in Tx sxmb_moni with the text:
    Error Text:" Runtime exception occurred during application mapping com/sap/xi/tf/_MM_ProxyResponseTo_SoapRespo~;
    com.sap.aii.mappingtool.tf7.IllegalInstanceException: Cannot create target element /ns0:MT_SOAPResponse/Message_Type.
    Values missing in queue co~".
    The point to be noted is that target element /ns0:MT_SOAPResponse/Message_Type is not there and I have activated the deleted objects. I am not using this element in any  MM and OM.
    Part3
    For 1 request message, I am receiving, 2 response  from SAP ECC . What is the issue here.
    Can anyone help me on both the querries and where I can improve my design aspects?
    Regards
    Alice~
    Edited by: Alice@xi on Jan 23, 2012 7:15 PM

    Part1: Your design is fine.
    Part2: Looks like you are doing synchronous scenario. Just make sure in the service interface you referenced request and response correctly. This is for both outbound and inbound service interface. Also you have two mapping object one for the request and the second one for the response. You have to reference the first request mapping object for request in the operation mapping and the second response mapping object for response in the operation mappng. Make sure you do right. Also if you delete all the unwanted objects  and reference only live objects in the mapping and service interfaces you will not have delete issue.
    Part 3: You might have to regenerate sproxy once again after deleting the unwanted objects in ESR/IR. Check how many message types you get after this. You should one each for request and response. Not two for response. Hope you sproxy for the target structure inbound service interface.
    Hope that helps.

Maybe you are looking for

  • Can not foward into voicemail from outside call on CUE and CUCM 8.6

    Dear Team, I have CUE Utility and CUCM 8.6. I can call from local, if user busy or go out office then call will foward to voice mail.It is ok. But when i call from outside to my phone(direct line), then call can not foward to voice mail on CUE. Pleas

  • Please help - Photoshop won't open

    Hi, I just bought photoshop elements, installed it and everything was fine.  Like a dope, I downloaded a graphic from a website, and tons of adware/malware was also loaded on my computer.  I couldn't stand all the popups and junk, so i used the Dell

  • THIRD PARTY -MIGO

    IN THIRD PARTY TRANSACTION STASTICAL MIGO BY MOVEMENT TYPE-101 IS POSSIBLE? IF YES PLEASE EXPLAIN THE STEP FOR THE SAME TO ACTIVATE.

  • DMS Search on individual metadata characterstics.......

    Hi, WE are using DMS connector for KM and acessing documents from SAP content server. The requirement is to search on individual DMS metadata characterstics but KM offers only one pre-defined property for all the characterstics and while searching th

  • Migration to new Macpro...Then what?

    I recently used Migration assistant to move my old system to my new Mac via Plugging my old SATA drive into my new Macpro.....this worked well so far but now I need to "DEAUTHORIZE" my old computer with Itunes....... Can I just start up under my old