Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
deleted 5 characters in body
Source Link
Borja
  • 99
  • 11

is this pseudo-code?

If not I would rewrite it like:

$form = $('#form_id'); function hide_element() { $$form.hide('#form_id'); $form.hidesubmit(); } function show_element() { $$form.show('#form_id'); $form.showsubmit(); } 

And then:

<button onclick="show_element();">show</button> <button onclick="hide_element();">hide</button> <form> ... </form> 

I removed the type submit because it is not good to have more than one submit. Actually both are outside the form. In case you want to submit it I would put it like this:

<button onclick="show_element(); $('#form_id').submit()">show<;">show</button> <button onclick="hide_element(); $('#form_id').submit()">hide<;">hide</button> <form> ... </form> 

is this pseudo-code?

If not I would rewrite it like:

function hide_element() { $('#form_id').hide(); } function show_element() { $('#form_id').show(); } 

And then:

<button onclick="show_element();">show</button> <button onclick="hide_element();">hide</button> <form> ... </form> 

I removed the type submit because it is not good to have more than one submit. Actually both are outside the form. In case you want to submit it I would put it like this:

<button onclick="show_element(); $('#form_id').submit()">show</button> <button onclick="hide_element(); $('#form_id').submit()">hide</button> <form> ... </form> 

is this pseudo-code?

If not I would rewrite it like:

$form = $('#form_id'); function hide_element() { $form.hide(); $form.submit(); } function show_element() { $form.show(); $form.submit(); } 

And then:

<button onclick="show_element();">show</button> <button onclick="hide_element();">hide</button> <form> ... </form> 

I removed the type submit because it is not good to have more than one submit. Actually both are outside the form. In case you want to submit it I would put it like this:

<button onclick="show_element();">show</button> <button onclick="hide_element();">hide</button> <form> ... </form> 
Removed the type submit below.
Source Link
Borja
  • 99
  • 11

is this pseudo-code?

If not I would rewrite it like:

function hide_element() { $('#form_id').hide(); } function show_element() { $('#form_id').show(); } 

And then:

<button onclick="show_element();">show</button> <button onclick="hide_element();">hide</button> <form> ... </form> 

I removed the type submit because it is not good to have more than one submit. Actually both are outside the form. In case you want to submit it I would put it like this:

<button type="submit" onclick="show_element(); $('#form_id').submit()">show</button> <button type="submit" onclick="hide_element(); $('#form_id').submit()">hide</button> <form> ... </form> 

is this pseudo-code?

If not I would rewrite it like:

function hide_element() { $('#form_id').hide(); } function show_element() { $('#form_id').show(); } 

And then:

<button onclick="show_element();">show</button> <button onclick="hide_element();">hide</button> <form> ... </form> 

I removed the type submit because it is not good to have more than one submit. In case you want to submit it I would put it like this:

<button type="submit" onclick="show_element(); $('#form_id').submit()">show</button> <button type="submit" onclick="hide_element(); $('#form_id').submit()">hide</button> <form> ... </form> 

is this pseudo-code?

If not I would rewrite it like:

function hide_element() { $('#form_id').hide(); } function show_element() { $('#form_id').show(); } 

And then:

<button onclick="show_element();">show</button> <button onclick="hide_element();">hide</button> <form> ... </form> 

I removed the type submit because it is not good to have more than one submit. Actually both are outside the form. In case you want to submit it I would put it like this:

<button onclick="show_element(); $('#form_id').submit()">show</button> <button onclick="hide_element(); $('#form_id').submit()">hide</button> <form> ... </form> 
Source Link
Borja
  • 99
  • 11

is this pseudo-code?

If not I would rewrite it like:

function hide_element() { $('#form_id').hide(); } function show_element() { $('#form_id').show(); } 

And then:

<button onclick="show_element();">show</button> <button onclick="hide_element();">hide</button> <form> ... </form> 

I removed the type submit because it is not good to have more than one submit. In case you want to submit it I would put it like this:

<button type="submit" onclick="show_element(); $('#form_id').submit()">show</button> <button type="submit" onclick="hide_element(); $('#form_id').submit()">hide</button> <form> ... </form>