www.webdeveloper.com
Results 1 to 6 of 6

Thread: Another not working in FF

  1. #1
    Join Date
    Nov 2010
    Posts
    3

    Another not working in FF

    Can't get the ?aa=___ to even show in FF...

    Code:
    <script type="text/javascript">
    function submitForm(containerElement) {
    	var theForm = document.createElement("form");
    	   theForm.action = 'http://www.google.com?name=' + document.getElementsByName('aa')[0].value;
               theForm.method = "get";
               theForm.innerHTML = document.getElementById(containerElement).outerHTML;
    	   theForm.submit();
            var formToSubmit = document.body.appendChild(theForm);
               formToSubmit.submit();
    }
    </script>
    <div id="searchForm">
        <input id="aa" name="aa" type="text"/>
        <a href="#" onclick="submitForm('searchForm');return false">
    		<img alt="Search" src="./go.gif" />
    	</a> 
    </div>

  2. #2
    Join Date
    Mar 2007
    Location
    U.K.
    Posts
    1,127
    Quote Originally Posted by pjavan View Post
    Can't get the ?aa=___ to even show in FF...

    Code:
    <script type="text/javascript">
    function submitForm(containerElement) {
        var theForm = document.createElement("form");
           theForm.action = 'http://www.google.com?name=' + document.getElementsByName('aa')[0].value;
               theForm.method = "get";
               theForm.innerHTML = document.getElementById(containerElement).outerHTML;
           theForm.submit();
            var formToSubmit = document.body.appendChild(theForm);
               formToSubmit.submit();
    }
    </script>
    <div id="searchForm">
        <input id="aa" name="aa" type="text"/>
        <a href="#" onclick="submitForm('searchForm');return false">
            <img alt="Search" src="./go.gif" />
        </a> 
    </div>
    I see no reference to ?aa=___, however this code doesn't stand a chance.

    outerHTML isn't supported by all browsers.

    Form elements written using innerHTML probably won't be successful (submitted).

    Once you submit a form, the document is dismissed and it is not possible to perform any further operations reliably.

    Maybe you should explain from scratch what you're trying to do.

  3. #3
    Join Date
    Nov 2010
    Posts
    3
    I need this section here, to do a form submit. This code is pulled from a blog that I referenced to do a form submit inside of SharePoint. The "aa" needs to append the URL as a query string parameter.

    Code:
    <div id="searchForm">
        <input id="aa" name="aa" type="text"/>
        <a href="#" onclick="submitForm('searchForm');return false">
            <img alt="Search" src="./go.gif" />
        </a> 
    </div>

  4. #4
    Join Date
    Dec 2002
    Location
    St. Louis, MO, USA
    Posts
    1,582
    All javascript (for the function) is ignored after "theForm.submit();" (this actually submits the form; everything after isn't even looked at.)

    Why create the form on the fly? Why not create the form static, and _then_ use JavaScript to submit?

    I agree with Logic Ali - this doesn't stand a chance.

    ^_^

  5. #5
    Join Date
    Nov 2010
    Posts
    3
    All javascript (for the function) is ignored after "theForm.submit();

    Not sure I agree with that statement. I've added alerts after that and I still get to them.

    I'm really not a JS guy. What does use the form static mean? I can't use a form tag in the HTML as this code sits inside of SharePoint. It has to be in a Div Tag.

  6. #6
    Join Date
    Dec 2003
    Location
    Bucharest, ROMANIA
    Posts
    15,428
    Quote Originally Posted by pjavan View Post
    I can't use a form tag in the HTML as this code sits inside of SharePoint. It has to be in a Div Tag.
    No. A form element should be nested inside a FORM tag, even if it is placed in a DIV (as its immediate parent), that's not negotiable. You can not bend the language to suit your conditions, you should change the conditions to suit the language.
    Last edited by Kor; 11-24-2010 at 04:07 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles