Change action and image src url's with jQuery

I am parsing a form from another one of my sites using a php proxy. It is working fine but the form action and img src of the submit button url's are relative. How can I prepend the full http//www.domain.com/ in front of each of the url's in the form?

Edit:

Here's the form code once fed through to the new domain:

 <div style="display: none;" id="SubscribeForm" class="newform">

            <h5>Subscribe to our newsletter</h5>

            <form action="/CampaignProcess.aspx?ListID=27057" method="post" onsubmit="return checkWholeForm93426(this)" name="catemaillistform93426">

                <div class="form">

                <div class="item">

                <label for="CLFullName">Full Name</label>

                <br />

                <input type="text" maxlength="255" id="CLFullName" name="FullName" class="cat_textbox_small" style="background-color: #ffffa0;" />

                </div>

                <div class="item">

                <label for="CLEmailAddress">Email Address</label>

                <br />

                <input type="text" maxlength="255" id="CLEmailAddress" name="EmailAddress" class="cat_textbox_small" style="background-color: #ffffa0;" />

                </div>

                <div class="item">

                <label>Enter Word Verification in box below</label>

                <br />

                <div class="captchaimg"><img src="/captchahandler.ashx?ID=22791bf65054422cadeb4aea9390cfaa&amp;Color=DimGray&amp;ForeColor=White&amp;Width=160" alt="Captcha Image" /></div>

    <input id="CaptchaV2" class="cat_textbox" type="text" name="CaptchaV2" style="width:160px" />

    <input id="CaptchaTV2" type="text" name="CaptchaTV2" style="display:none;" />

    <input id="CaptchaHV2" type="hidden" value="22791bf65054422cadeb4aea9390cfaa" name="CaptchaHV2" />



                </div>

                <div class="item">

                <p>We respect your privacy and will never share your details.</p>

                </div>

                <div class="item">

                <input type="image" src="/images/submit-button-white-bg_07.gif" id="catlistbutton" value="Subscribe" class="cat_button" />

                </div>

                </div>

                <script type="text/javascript" src="http://testsite.businesscatalyst.com/CatalystScripts/ValidationFunctions.js"></script>

                <script type="text/javascript">function checkWholeForm50598(theForm){var why = "";if (theForm.EmailAddress) why += checkEmail(theForm.EmailAddress.value);if (theForm.CaptchaV2) why += isEmpty(theForm.CaptchaV2.value, "Enter Word Verification in box below"); if (why != ""){alert(why);return false;}theForm.submit();return false;}</script>

            </form>
</div>

and here's the jQuery I am using to try and change the action url:

jQuery(document).ready(function($) {
  $('form').each(function(index) {
    var urls = $(this).attr('action');
    var dom = 'http://www.sampleurl.com';
    $(this).attr('action',dom+urls);
  });
});

All other jQuery functions are working well on the page so I know it is not an issue with jQuery itself.

Answers


well start of reading the original url

$('img').each(function(index) {
    var urls =$(this).attr('src');
    var dom = 'http://domain.com';
    $(this).attr('src',dom+urls);

  });

that will change all the image urls might be another way but this works just as good

checkout here

http://www.jsfiddle.net/LewEB/


Need Your Help


About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.