JQuery :: Change Form Action Based On Button Clicked?

Jun 12, 2009

I have a form like this:

<form id="my_form" method="post" action="">
Name: <br />
<input type="text" id="name" name="name" />
<input type="submit" id="submit1" value="Go to page 1" />
<input type="submit" id="submit2" value="Go to page 2" />
</form>

how can I change my action form so the form goes to Page1.htm with click on button1 and goes to Page2.htm to click on button2, and mantein the value inserted in textbox "name"?

View 4 Replies


ADVERTISEMENT

Multiple Action Done By Clicked Button

Jun 22, 2009

I have window containing a field.I was looking for a way to copy the value in the field and at the same time close the window.To close window i cleaned the copying code and insert this : 'javascript:window.close();' it worked perfectly too.But i don't know how to put the 2 codes in one line so that on click the button will copy the field value and close the window

View 1 Replies View Related

Submit Button Action Based On Different Conditions?

Mar 16, 2011

I want my submit button to link to different pages, based on the value of a particular variable (let's call it total).

So, if 18 < total < 20, the submit button should redirect to page1.html
If 16 < total < 18, the submit button should redirect to page2.html
If 14 < total < 16, the submit button should redirect to page3.html

I have created page1.html, page2.html....page10.html. how should I link my submit button (I have only *one* submit button) to different pages based on different conditions?

View 9 Replies View Related

JQuery :: Submitting Information Based On Which Form Was Clicked

Dec 8, 2010

I've been doing PHP for a couple months, but just came across jquery today. I'm making a wedding-registry-style wishlist site for the holidays, and one of my pages is a list of all the items on your wishlist for you to modify.

Here is my jquery script, which I had learned from a tutorial:
<script type="text/javascript">
$(function() {
$(".submit1").click(function() {
var item_name = $("#item_name").val();
var item_notes = $("#item_notes").val();
var imgid = $("#imgid").val();
var price = $("#item_price").val(); .....
var dataString = 'item_name='+ item_name + '&imgid=' + imgid + '&price=' + price + '&item_notes=' + item_notes;

$.ajax({
type: "POST",
url: "edit.php",
data: dataString,
success: function(){
$('.success').fadeIn(500).fadeOut(500);
}});
return false;
});
});
</script>

My forms are structured like so:
// PHP WHILE STATEMENT
// Retrieve data about item
<form>
<input type="hidden" name="imgid" id="imgid" value="<?=$imgid?>">
<input name="item_name" type="text" id="item_name" value="<?=$item_name?>" />
<input name="item_notes" type="text" id="item_notes" value="<?=$item_notes?>" />
<input name="item_price" type="text" id="item_price" value="<?=$price?>" />
<input type="image" class="submit1" src="images/edit_item.png" border="0" />
<span class="success" style="display:none">Item updated!</span>
</form>
// END WHILE STATEMENT

Now, the problem is obviously that when this HTML code gets repeated, all the forms have the same input IDs. I tried adding numbers to the form using php, so it would be something like "item_name1", "item_name2", "item_name3", etc depending on the form, but then I realized I don't know how to pass parameters into the jquery function.

Is there any way to do this? So that it's something like...
$(function() {
$(".submit1").click(function() {
// Find parent form (which would have the ID "1", "2", "3", etc.)
// var id = parent form ID
// Get info from "item_name1" if form "1" was submitted
// Get info from "item_name2" if form "2" was submitted
// Etc.
var item_name = $("#item_name"+id).val();
var item_notes = $("#item_notes"+id).val();
var imgid = $("#imgid"+id).val();
var price = $("#item_price"+id).val();
// declare datastring
// ajax
return false;
});
});

View 1 Replies View Related

AJAX :: Updating FORM Action Based On Input

Aug 2, 2011

Let me preface this by saying that I have ZERO experience with Ajax, and have simply copied this code from a blog elsewhere. What is shown below ties to a php file that I developed for a search function on our site. As the user enters their search term(s) in the text input field, the div below is populated with potential results through AJAX. I get all that.

However, I'd like to extend this a bit more. I'd like to enable to user to click the Enter key to follow the URL of the top search result automatically, without having to move their mouse and click on it.

Since I'm using PHP to generate the actual URL, I'm sure I can just send this back as a variable via AJAX, but with my lack of understanding, I thought I'd poke around here for some assistance. Can someone show me how to tweak the code below to accomplish what I'm looking for?

Code:

<script type="text/javascript">
function showResult(str)
{
if (str=="")

[Code].....

I'm less concerned about getting the Enter key to perform the submit than I am about passing the URL variable back to the form via AJAX. I've seen lots of examples of getting the Enter key to behave this way, I just didn't want to muddy up the original code above.

View 4 Replies View Related

Change Form Action URL On-the-fly?

Jan 20, 2009

I want to change a form action url based on user input, and I used hyperlink to submit a form (since I have lots of rows like this and each has different values passed to javascript select_claim() function.). But it doesn't work! I have very simple php code here, but the it is the javascript problem.

HTML Code:
<form action="" method="post" name="smForm" id="smForm">
<table>

[code].....

View 10 Replies View Related

How To Change Images Based On Action.Even Clicking Changed Images Should Do Respective Actions?

Jan 12, 2007

how to change images based on action. Even clicking changed images should do respective actions. and while displaying only one image at a time sholud get displayed. I am using three images for a single column of a table in Jsp. Code:

View 3 Replies View Related

Action Url Change On Submit Form

May 23, 2007

Is it possible to change URL form action on submit form...

I have tried such code:

<script language="JavaScript" type="text/javascript">
function changeURL()
{
......

View 1 Replies View Related

Change Form And Action And Then Auto-Submit?

Nov 9, 2011

I have a body onload doing multiple things, changing a select option value, changing the form submit action and then auto submitting. Everything works fine until the auto submit part of it.

function run()
{
document.myform.myselect.selectedIndex = 1;
document.myform.action = 'page.php?x=1&y=2';
document.myform.submit();
}
<body onload="run()">

View 2 Replies View Related

Form Action Url Selection On Radio Button Value

Jul 5, 2005

I have 2 radio button first is a and second is b.

If a is selected then the form action should be a.php or b is selected then b.php.

Any idea how to do this. I don't want to this in server side script.

View 3 Replies View Related

Change The Position Of A Div When A Button Is Clicked?

Jan 27, 2010

Im trying to change the position of a div when a button is clicked.

The js is:

function curPos() {
objDivStrip = document.getElementById('thumbview');
return objDivStrip.style.top;

[Code]....

View 1 Replies View Related

Make Button Change Text When Clicked?

Jun 16, 2009

On my site I have a file uploader.
<table align="center"class="table">
<tr>
<td class="table_header" colspan="2"><b><?=$websitename;?></b> </td>
</tr><tr>
<td colspan="2" class="upload_info">
<b>Allowed Types:</b> <?=$types?><br />
<b>Max size per file:</b> <!--<?=$max_file_size?>-->50MB.<br />
<b>Max size for all files combined:</b> <!--<?=$max_combined_size?>-->150MB.<br />
</td></tr>
<?For($i=0;$i <= $file_uploads-1;$i++) {?>
<tr>
<td class="table_body" width="120%"><b>Select File:</b> </td>
<td class="table_body" width="120%"><input type="file" name="file[]" size="30" /></td>
</tr><?}?><tr>
<td colspan="2" align="center" class="table_footer">
<input type="hidden" name="submit" value="true" />
<input type="submit" readonly value=" Upload File(s) " />
<input type="reset" name="reset" value=" Reset Form " />
</td></tr><tr></table>

What I want it to do is when they have clicked upload file(s) I want that to change to "your files are being uploaded" and make the button unclickable?

View 4 Replies View Related

Change Text/Value On Button When Clicked Not Working In FF?

Dec 4, 2010

Basically I am looking to show/hide a DIV with the click of a button.The script work accordingly in IE but fail in FF.I am sure I am the problem here.

Code:
<script type="text/javascript">
function toggle(box) {

[code]....

View 1 Replies View Related

Trigger Two Action In One Form / When User Click Single Button

Feb 3, 2010

how i can trigger two action in one form when user click a single button

View 8 Replies View Related

Clicked Radio Button Text To Change Colour

Mar 3, 2005

i made a quiz using radio buttons and ofcourse javascript,but to further customized my quiz i want an event handler in which it will change the text color attached to a particular radio button when the user clicks an option.

View 1 Replies View Related

Unwanted Cursor Change When The Button Is Clicked - Internet Explorer 6

Mar 2, 2010

[Code]....

My example code causes the following problem in Internet Explorer (at least, in version 6): it causes an unwanted cursor change when the button is clicked. DETAILS: Using my example code, here is what happens (step-by-step in chronological order): (1) the user hovers the mouse over the button, which causes the cursor to be a hand; (2) the user clicks the button; (3) the browser does its image-related activity; (4) immediately after step 3 is entirely completed (in other words, after the browser finishes loading an available image or after the browser times out from attempting to find an unavailable image), the cursor changes from a hand to an arrow if the mouse is kept still; (5) if the mouse is then moved while staying over the button, the cursor will change back to a hand.

As I said, in step 4, the cursor changes from a hand to an arrow if the mouse is kept still. I consider that to be a problem because I want the cursor to *always* be a hand when it is over the button. And, indeed, that should be the expected behavior due to the CSS code (style="cursor:pointer") in the button tag.

QUESTION #1: The problem occurs in IE6, which is the only version of IE available to me. Does the problem also occur in later versions of IE? (The problem does not occur in Firefox.)

View 4 Replies View Related

Select Radio Button And Change Style When Table Cell Is Clicked?

Jul 3, 2007

I have this code that changes the color of the table cell when it is moused over, but I would like to also have it do this:

select radio button when cell is clicked.
change class to blue3 when clicked and leave it like that until another is clicked.
Continue changing color on mouseover. Code:

View 4 Replies View Related

Set A Form Variable When Button Is Clicked?

Jul 6, 2010

Set a form variable when button is clicked

View 1 Replies View Related

Change Button Text Based On CheckBox Checked Or Not

Apr 7, 2009

Currently on my page [PHP5] I have a checkbox & a input button (among other things), the button text now is hardcoded to "Next" but I need this to change based on the status of the Checkbox (cBusAcc). For example, when cBusAcc is not checked the button should be "Create", when it is checked the button should be "Next".

And this change should occur without the user needing to press on the button, just check/uncheck should change the button test...
See the code I have so far below...

...
<input type="checkbox" name="cBusAcc" id="cBusAcc" />
<input name="signup" id="signup" type="submit" value="Next" />

View 1 Replies View Related

Change A Label At Page Load Based On Radio Button

Mar 2, 2010

I have a webpage which has two radio buttons. There is a label also in the web page. I want the label string to be based on the radio button status. I am able to change when somebody press the radio button using "onclick" function, but now when the page is reloaded.

Here is my code

Code:

I want the highlighted label value to be changed based on the radio button value at the start up itself( ie if the page get reloaded if some error has happend at filling the form)

View 2 Replies View Related

JQuery :: Show/hide Form Elements Based On Radio Button Selections ?

Mar 17, 2011

I have a set of radio buttons on my pricing page:

And a corresponding text_field input element div I'd like to display based on which radio button the user selects:

When the page loads, I'd like to see:

When the user clicks on a (different) radio button, or clicks one for the first time, I'd like whichever div is currently showing to be hidden, and the newly selected one to be shown.

Right now I have jQuery code at the bottom of my page that looks like this:

For each of the four options.

When the page loads, the correct div is shown, and when I select a new button, the new div is shown, but the already showing one isn't hidden.

I've read some posts that suggest using change() instead of click(), but others indicate that's problematic in IE.

View 1 Replies View Related

Changing The Action Of A Form With An Input Named Action?

Feb 16, 2009

I have come across a very interesting problem that seems to be impossible to solve. Basically a web application that I am working on relies on a JavaScript function called go to change the input named view to the page name and submit the form. This form's type is post, so no values are included in the actual URL string. There is also another input called action and it's value is view. This is to tell the application that the user would like to view a page. The problem is because of the variables being of method post, page refreshes and back and forwards return errors because the post variables view and action aren't sent with the required data. To somewhat solve this problem I have created a feature that tells the application that if the post value page is empty then to try and get a GET var called page. To insert this var into the go javascript function I simple add this code

document.go.action = document.go.action+"&page="+page;

This line basically adds &page=[page] to the action of the form. The problem is, this code doesn't work because action is also the name of a form element. Referencing document.go.action refers to the input element named action and not to the form's action. Changing the named of the action input value is out of the question (Way to much changing of code, and possible room for error). What can I do to change the action of the form without referencing the input named action. Here is my go form and the JavaScript code:

<form name="go" action"index.php?sid=123" method="post">
<input type="hidden" name="action" value="view" />
<input type="hidden" name="view" value="" />
</form>

[Code]....

View 6 Replies View Related

JQuery :: Submit And Reloading Form Values After Submit Button Is Clicked?

Jul 13, 2011

In the following .submit function, I am attempting to grab the value of the selected option in the facilityCodes dropdown list when I click the submit button and then during the submit function,select the facilityCode again in the dropdown list when the page reloads and then disable the list so that the user cannot change it.However,the situation is when I reload the page after the submit button is clicked the dropdown defaults to the first option and the list is enabled.I apparently am not understanding how.submit works so that I'm selecting the option I'm defining in my code below and then disabling the list AFTER the page reloads due to an error on the page. My question is how can I accomplish this?Here is my code:

$(function() {
$("#ARTransferForm").submit(function() {
var msgsCount = 0;[code]....

View 1 Replies View Related

Change Form Based On Previous Input

May 7, 2009

I was wondering if it's possible to make it so that once a user selects a certain option in a list, it makes the next input for that form change to either a textfield or a list without losing the values entered in the inputs above.I know PHP is a server-side script, does that make this not possible?

View 3 Replies View Related

Change A Form Based On Select Option?

May 25, 2009

I don't know if this is something you could do without JavaScript, but anyways... I want to make a drop down menu that changes a form based on the option, like if I chose Option1, it would show Form1 and so on.

View 2 Replies View Related

Change Form Based On Dropdown Selection

Sep 23, 2011

I have a dropdown box with 2 selections(True/False default False) .If false I want to show under it a form like so.

input text
input check
input text

View 9 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved