Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Aug 2008
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts

    onclick this.src function problem?

    I guess it is because it is 2am and had a few beers but i cannot get this to work and i know its pretty simple to do - see the code below:

    Code:
    {if ""|fn_needs_image_verification == true}
    	{assign var="is" value="Image_verification"|fn_get_settings}
    	
    	<p{if $align} class="{$align}"{/if}>{$lang.image_verification_body}</p>
    	{assign var="id_uniqid" value=$id|uniqid}
        
        {literal}
    	<script language="javascript" type="text/javascript">
        function reloadCaptcha() {
            captcha = document.getElementById("captureURLID").src;
    		return captcha += 'reload';
        }
        </script>
        {/literal}
    
    	{if $sidebox}
    		<p><img id="verification_image_{$id}" class="image-captcha valign" src="{"image.captcha?verification_id=`$SESS_ID`:`$id`&amp;`$id_uniqid`&amp;"|fn_url:'C':'rel':'&'}" alt="" onclick="this.src += 'reload' ;" width="{$is.width}" height="{$is.height}" /></p>
    	{/if}
    
    	<p><input class="captcha-input-text valign" type="text" name="verification_answer" value= "" autocomplete="off" />
    	{if !$sidebox}
    		<img id="verification_image_{$id} captureURLID" class="image-captcha valign" src="{"image.captcha?verification_id=`$SESS_ID`:`$id`&amp;`$id_uniqid`&amp;"|fn_url:'C':'rel':'&'}" alt="" onclick="this.src += 'reload' ;"  width="{$is.width}" height="{$is.height}" />
    	{/if}
        <img src="{$images_dir}/icons/icon_reload.png" height="25" width="25" alt="Reload Captcha Image" onclick="reloadCaptcha();" class="valign image-captcha" /></p>
    {/if}
    now the following works totally fine, when you click the captcha code changes..... "onclick="this.src += 'reload'" you will notice i have added a custom reload button image below this with a onclick calling a custom function "reloadCaptcha(); which i want to reload the captcha image above it - however it is not working, i have done the function so it grabs the src from the element ID, i have added 2 ID's to the IMG but cannot remember if you can have multiple IDs or not which if not could be causing the problem but not 100% sure how to include the smarty code for the generated ID on that image.

    Any ideas on the code above from having a quick glimps? as the code stands i get the error:

    Error: captureURL is null

    Many Thanks

  • #2
    Banned
    Join Date
    May 2006
    Location
    England
    Posts
    664
    Thanks
    0
    Thanked 84 Times in 84 Posts
    It would be easier to interpret the code if you'd post it as rendered.

    An element can have only one ID which must be unique and should not include spaces.

    Quote Originally Posted by oneline View Post
    as the code stands i get the error:

    Error: captureURL is null
    I don't see a reference to an object of that name.

    _

  • #3
    New to the CF scene
    Join Date
    Aug 2008
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts
    i guess the main issue them is with me trying to use multiple IDs, amazing how i forgot that! i guess its because i hardly use IDs anymore and only classes when coding!! haha as i need to contain the ID within the element i will either have to work out how to use the smarty code within the JS as it currently does not output the {$id} park when rendering or to call using a class instead - in that case i think i will do using jQuery to perform this task instead as the LIB is already loaded within the software.

    Thanks for your time in replying Ary!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •