Simple Remove text from attribute value

E

eggie5

This is a snippet from my page:

<form name="form1" method="post" action="Default.aspx?id=365272"
id="form1" enctype="multipart/form-data">

I need some javascript that can check if the id query string is in the
action attribute, and if it is, remove it so the form element will look
like this:

<form name="form1" method="post" action="Default.aspx" id="form1"
enctype="multipart/form-data">

Thanks.
 
L

Lee

(e-mail address removed) said:
This is a snippet from my page:

<form name="form1" method="post" action="Default.aspx?id=365272"
id="form1" enctype="multipart/form-data">

I need some javascript that can check if the id query string is in the
action attribute, and if it is, remove it so the form element will look
like this:

<form name="form1" method="post" action="Default.aspx" id="form1"
enctype="multipart/form-data">

No, what you want is to replace the action attribute value with
the current value with anything after and including a "?" removed.

off the top of my head, that's
document.form1.action=document.form1.action.replace(/\?.*/,"");


--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,280
Latest member
BGBBrock56

Latest Threads

Top