Jump to content

create new input text box in the same page when pressinh button


Recommended Posts

I am trying to do that when someone will press the button, it will create in the same page new input textbox, what I did is:

function blabla()
{
document.write("<tr><td> bla")
document.write(":</td><td><input name='Option")
document.write("' type='text' /></td></tr>") 
}

Everything is great, it does make a new textbox but it clears the page and then makes only new text box..I want it to create new text box in the same page, below the button, how?

thanks.

put the style="display:'none;'" in the tr instead of the td

Ok, done..now it works but to show it I do style="display:'block;'", in IE it works fine but in FIREFOX it is not working good and table messes up, how can I solve it?

remove the single quotes:

style="display:none", not style="display:'none;'"

 

edit:

and another thing: for firefox (and every standards compilant browser for that matter) you should set style="display:table-cell" for tds, not block. You'll have to do some browser checking because IE doesn't recognise table-cell for display property.

actually, don't use display:block;

 

Not sure you set the script up, but here is what works

 

Let's say this is your html (notice the id in the tr tag)

<tr id="TR_ID" style="display:none;">
.....
</tr>

 

Your button will call the following Javascript function once clicked

<script>
function show_tr(){
document.getElementById('TR_ID').style.display = "";
}
</script>

You can add an if statment to toggle the display between "none" and "";

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.