Jump to content

hidden input


ilikephp

Recommended Posts

hi,

 

I have a form that contains a submit button, when all the fields are checked I need another button to be appeared, How can I do it plz? Thx...

 

<input type="submit" name="submit" id="Submit" value="submit" />
<input type="hidden" name="submit" value="1" />

Link to comment
Share on other sites

Do you really need to show/hide a second submit button? Your example code would seem to indicate you only need to change the value of the current submit button. Anyway the code below will show/hide the second submit button:

<html>
<head>
<script type="text/javascript">

function checkFields()
{
    if (document.getElementById('field1').value!='' &&
        document.getElementById('field2').value!='' &&
        document.getElementById('field3').value!='')
    {
        document.getElementById('submit2').style.visibility='visible';
    }
    else
    {
        document.getElementById('submit2').style.visibility='hidden';
    }
    return;
}

</script>
</head>
<body>

Field 1: <input type="text" name="field1" id="field1" onkeyup="checkFields();" /><br />
Field 2: <input type="text" name="field2" id="field2" onkeyup="checkFields();" /><br />
Field 3: <input type="text" name="field3" id="field3" onkeyup="checkFields();" /><br />

<input type="submit" name="submit" id="Submit" value="submit" />
<input type="submit" name="submit2" id="Submit" value="1" style="visibility:hidden;" />

</body>
</html>

Link to comment
Share on other sites

Once you click submit the page is submitted and will reload. You could have the buttin show as soon as you click submit, but it will only display for a fraction of a second before the page reloads. I think you need to clearly explain what you are trying to accomplish.

Link to comment
Share on other sites

I have a registration form:

when I fill in all the fields, I need to click on the send button so all the fields will be checked for validation;

if all the fields are correct, the submit button will appear and a new page will be opened when I click on the submit button.

 

I need this submit button to be appeared if there are no errors. I put it as hidden, how to let it be visible? Thx...

Link to comment
Share on other sites

OK, so the first button really isn't a submit button at all!

 

In this situation you don't want to use two "submit" buttons anyway. If you had simply stated your objective in the beginnign we wouldn't have wasted this time.

 

If you want to do JavaScript validation you simply need to create an onsubmit event that will perform the validation and send the form if validation passes and if validation fails halt the fiorm submission and display the errors.

 

You just need to create a javascript function to perform the valiaftion and return true if there are no errors and return false if there are errors. Then in the FORM tab put an onsubmit trigger like this

<form name="theform" onsubmit="return validate();">

Link to comment
Share on other sites

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.