Novice Scripting Help

0

The script below works, up until the point where I try to populate a hidden value with the ext_id

 

http://screencast.com/t/82X4UVU4JGk

 

What am I doing wrong?

 

<script type=”text/javascript”>

</script>

<script type=”text/javascript” src=”https://maps.royalcanin.be/api/client/client.js”></script>

<div id=”partner_map” style=”width: 600px; height: 600px”></div>

<script type=”text/javascript”>
rcPartnerLocator.create(‘#partner_map’, {
id: 36,
markers: {
infoWindow: {
eventType: ‘js’,
onSelected: function (partner) {
alert(“name = ” + partner.pub_name + “\n” + “ext ID = ” + partner.ext_id);

// if you want to view all returned data, you can look at this in your inspector window
console.log(partner);
}
}
}

});
sgapiSetValue(8, partner.ext_id);

</script>

Alex Walker answered
    0

    I feel as if I’m getting there slowly, but just not enough knowledge to actually make this work.

     

    The below works in HTML outside of SG, but I can’t seem to make the final leap to get the code to populate a text field in SG.

     

    </script>

    <script type=”text/javascript” src=”https://maps.royalcanin.be/api/client/client.js”></script>

    <div id=”partner_map” style=”width: 600px; height: 600px”></div>

    <script type=”text/javascript”>
    rcPartnerLocator.create(‘#partner_map’, {
    id: 36,
    markers: {
    infoWindow: {
    eventType: ‘js’,
    onSelected: function (partner) {
    alert(“name = ” + partner.pub_name + “\n” + “ext ID = ” + partner.ext_id);
    sgapiSetValue(8, partner.ext_id);
    // if you want to view all returned data, you can look at this in your inspector window
    console.log(partner);
    }
    }
    }

    });<script type=”text/javascript” src=”https://maps.royalcanin.be/api/client/client.js”></script>

    <div id=”partner_map” style=”width: 600px; height: 600px”></div>

    <script type=”text/javascript”>
    rcPartnerLocator.create(‘#partner_map’, {
    id: 36,
    markers: {
    infoWindow: {
    eventType: ‘js’,
    onSelected: function (partner) {

    // prior warning
    // if (window.confirm(‘Are you sure you want to select ‘ + partner.pub_name + ‘ ?’)) {

    // show the form which was hidden by default
    // document.getElementById(“myform”).style.visibility = ‘visible’;

    // this is the code to simply complete the input field
    document.getElementById(“myfield”).value = partner.ext_id;

    // this is the code to simply complete a text value
    // document.getElementById(“myspan”).textContent = partner.pub_name;

    }

    // if you want to view all returned data, you can look at this in your inspector window –> just un-comment the next line
    // console.log(partner);
    }
    }
    }

    });
    </script>

    <form action=”” method=”post” id=”myform” style=”visibility:hidden;”>

    <!– title –>
    <h1>my super form</h1>

    <!– input field –>
    <input type=”text” name=”myfield” id=”myfield” size=”20″ maxlength=”50″ />

    <!– simple text –>
    <!– <div id=”myid”>
    The partner select is <span id=”myspan” style=”font-weight:bold;”>…</span>
    </div>–>

    </form>

    Alex Walker answered
      0

      Yes, after posting and reading around, I realised my mistake!

      I think that the link that you’ve provided is what I’m looking for, it’s just that whilst I’m quite resourceful, I just don’t have enough knowledge to apply that in this scenario. Can you help me further, maybe with an example using my code?

      Alex Walker answered
        0

        The last part here:

        sgapiSetValue(8, partner.ext_id);

        is a SurveyGizmo Custom Scripting function (PHP based rather than Javascript). You will need to use Javascript here. I found this online which hopefully will be helpful:

        http://stackoverflow.com/questions/477543/how-do-i-assign-value-to-a-textbox-using-javascript

        Dominic Sharpe answered
          ×

          Login

          Question stats

          • Active
          • Views504 times
          • Answers3 answers
          • Followers1 follower