0

I have a pre compiled form which i need to insert a button into after a specific field with and ID of addr_postcode can any one show me how to, using javascript, add a button after the field which when clicked takes the value of the field and launches a new window with the value as part of the url. for example:

../DIR/default.aspx?postcode=postcode here

Thanks a nice simple one I hope!

HTML

<TR>
<TD vAlign=top>
<SPAN id=_Captaddr_postcode class=VIEWBOXCAPTION>Post Code:</SPAN>
<BR>
<SPAN id=_Dataaddr_postcode class=VIEWBOX>
<INPUT id=addr_postcode class=EDIT name=addr_postcode maxLength=10 value=test size=15><INPUT name=_HIDDENaddr_postcode type=hidden>
</SPAN>
</TD>
</TR>
1
  • 1
    Can you show us the precompiled code? Commented Sep 12, 2011 at 8:44

1 Answer 1

1

Try this:

    function makeButton() {
        var buttonDiv = document.getElementById("addr_postcode");
        var Button = document.createElement("input");
        Button.setAttribute("type", "button");
        Button.setAttribute("id", "ButtonClick");
        Button.setAttribute("value", "New button");
        Button.setAttribute("onclick", "btnClick(" + buttonDiv.value.toString() + ");");
        buttonDiv.appendChild(Button);
    }

    btnClick(URL) {
        window.open(URL,'','scrollbars=no,menubar=no,height=600,width=800,resizable=yes,toolbar=no,location=no,status=no');
    }
Sign up to request clarification or add additional context in comments.

3 Comments

Have you called the function anywhere in your document?
As the document is precompiled I have no access to the body tag so I am unable to put an unload function there can I put it somewhere else?
Mhmm I'm not sure. I wish I could be of more help. I'm sorry.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.