Jump to content
  • Advertisement
Sign in to follow this  
Brainx7

Is there any web code for making the input box dissappear when submit

This topic is 1485 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I mean like, instead of using php to send the input and all that stuff, just have the box disappear and just leave the text that was input, idk like maybe make the box invisible when you click submit

Edited by Brainx7

Share this post


Link to post
Share on other sites
Advertisement

Isn't it better to have the button disabled rather than mysteriously disappear?

 

document.getElementById("submitButton").disabled = true;

 

http://www.w3schools.com/jsref/prop_pushbutton_disabled.asp

 

You can also add css if you want your own style on the disabled button, according to this example:

 

 
Edit: Sorry, didn't notice that it was an input box and not a button.  Just hide the box like slicer4ever suggests. smile.png
 
Edit 2: Maybe you want to disable rather then hide anyway, since hiding things moves stuff around on the page, which in my opinion is an annoyance.
 
What I usually do, when I want to submit something, unless you want an edit box that works like in Facebook, which require a lot more code and no loading of pages, is:
 
1. User clicks submit.
2. Optionally disable the submit button.
3. Call a script server side to process the data.
4. The script then redirects you to another page after processing.
5. If the user now clicks the back button, you will not have the process script running again, no resubmit of data, but the page where the user entered his/her input.
 
So basically: 
getuserinput.php -> processuserinput.php (redirect to:) -> userinputresult.php
 
The browser only "sees" getuserinput.php and userinputresult.php in terms of browser history, the processuserinput.php is not in the history.
Edited by aregee

Share this post


Link to post
Share on other sites

Something like this?

 

Say you have the HTML:

<input type="text" id="txt">
<div id="adiv"></div>

From what you said above you want:

function HideText()
{
     var txt = document.getElementById("txt");
     var div = document.getElementById("adiv");

     div.innerHTML = div.value;
     txt.style.display = "none";
     div.style.display = "block";
}

And the div will have the following CSS:

#adiv{
     display: none;
}

I think this is what you want happy.png

Edited by OnlyAntony

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!