Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
General
GeneralPortable MacsHardwareNetworking
Applications
Mac ApplicationsEudoraFirefox / MozillaInternet ExplorerOutlook ExpressMS OfficeEntourageExcelPowerPointWordVirtual PCMedia PlayerOther MS Products
Programming
Mac ProgrammingCodeWarriorPerl
Country Specific
Australian Mac GroupUK Mac Group

Mac Forum / Applications / Internet Explorer / May 2004



Tip: Looking for answers? Try searching our database.

Error Adding Form Inputs With Javascript

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Adam - 21 May 2004 17:09 GMT
I have a javascript function that dynamically writes form inputs into an
html page. When I click a button, it adds a textbox. it looks something like
this:

function addI(IC_ID){
var t = document.getElementById('T' + IC_ID);
t.innerHTML = "<input type='text' name='f'>";
}

t refers to a <td>
It writes the textbox in fine and I can even put onchange javascript events
in the textbox. But when I hit submit for the form, these added form inputs
DO NOT get sent with the rest of the form. It works fine on a PC. Can anyone
help? Please. This is an important and late bug in a large program.
Skip Howard - 25 May 2004 04:58 GMT
Me to, I made a very simple test page. I did innerhtml = <input
type=text name=bla> and nothing.

> I have a javascript function that dynamically writes form inputs into an
> html page. When I click a button, it adds a textbox. it looks something like
[quoted text clipped - 10 lines]
> DO NOT get sent with the rest of the form. It works fine on a PC. Can anyone
> help? Please. This is an important and late bug in a large program.
Skip Howard - 27 May 2004 01:51 GMT
I found a work around. I thought I might share it.
IN IE for windows, you just say innerhtml="<input type=text
name="whatever">"

IN IE for MAC, this is broken into three steps.
1. Write the innerHTML section just like in PC IE
2. Write hidden fields in the document
3. upon saving, send the input fields into the hidden fields, then
send to the result page.
4. On the result page, check the browser and if it is a mac, read the
hidden fields, other wise use the regular names.

EX:
<script>
document.all("insertinfo").innerHTML = "<input type=text
name="txtinfo" id="txtinfo">

function submit_form()
{
if (document.all("txtinfo"))
{
document.all("MAC_txtinfo").value = (document.all("txtinfo").value)
}

document.all("form1").action = "results.asp"
document.all("form1").submit

}
</script>

<form name="form1" method="post">
text<span id="insertinfo" name="insertinfo"></span>
<input type="hidden" name="MAC_txtinfo">
<input type="button" name="submit1" value="submit"
onclick="submit_form();">
</form>

RESULTS PAGE:
dim macchk, info
'This is the servervariables line
if not( instr(1,UCASE(Request.ServerVariables("HTTP_USER_AGENT")),"WINDOWS")
> 1) then
 macchk = "mac_"
else
 macchk = ""
end if

info = request.form(macchk & "txtinfo")

Note: If you are adding innerhtml to a cell element, you may want to
do a cell.innerHTML = " "; and then cell.innerHTML = "<input type=text
name=whatever>"

> Me to, I made a very simple test page. I did innerhtml = <input
> type=text name=bla> and nothing.
[quoted text clipped - 13 lines]
> > DO NOT get sent with the rest of the form. It works fine on a PC. Can anyone
> > help? Please. This is an important and late bug in a large program.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.