Announcement

Collapse
No announcement yet.

.html?code into other info prompt

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    .html?code into other info prompt

    Hi one and all,

    Am trying to find a way of automatically updating the value within the other info question input attributed to products on the page..

    i.e. when someone visits a product page, it will be linked to using say domain.tld/acatalog/product1.html?code

    Some how using java script, need it to extract just the code after the ? within the URL and insert this into any other info prompts on the page.

    Have identified that each other info prompt can be identified by O_NETQUOTEVAR:PRODUCTREF, but getting it to easily identify how many forms are involved within the page (i.e. just 1 product or 6 products which have the other info prompt) is proving to be a pain.

    The answer is starring me in the face, but for the life of me, just can not find it.

    Any bright sparks into j scripting got some fresh ideas on this one.

    Cheers, Martin

    #2
    Code:
    var inputfields = document.getElementsByTagName('input');
    for ( var i = 0; i < inputfields.length; i++ )
      {
      if ( inputfields[I].name.substring(0,2) == 'O_' )
        {
        inputfields[i].value = 'Wowza';
        }
      }
    Norman - www.drillpine.biz
    Edinburgh, U K / Bitez, Turkey

    Comment


      #3
      Thanks Norman, got a bit distracted.

      Will have a play at getting this together:

      var loc = window.location;
      function getCode(str)
      {
      return (str.substring(str.indexOf("?") + 1, str.length));
      }

      function, into the inputfields[i].value = 'Wowza'; value area.

      Just my head is all awash with absolute rubbish tonight, and not even been drinking

      Thanks again.

      Comment


        #4
        Could not see it for looking:

        OK, this is what I ended up with, which worked nicely.

        <SCRIPT LANGUAGE="JavaScript1.1">
        var mycode = location.search.substring(1, location.search.length)
        var inputfields = document.getElementsByTagName('input');
        for ( var i = 0; i < inputfields.length; i++ )
        {
        if ( inputfields[i].name.substring(0,2) == 'O_' )
        {
        inputfields[i].value = mycode;
        }
        }
        </SCRIPT>

        Job done, and thanks for your help Norman.

        Comment

        Working...
        X