JavaScript - How To Distinguish Between Clicked Hyperlinks When Submitting A Form With Javascript?
Consider the following piece of code:
PHP Code: <form method='post' name='myform'> <input type='submit' name='sub' value='submit 1' /> <input type='submit' name='sub' value='submit 2' /> <a href='javascript:document.myform.submit();'>submit 3</a> </form> <?php echo "You clicked ".$_POST["sub"]; ?> So if you click "submit 1", the output will be You clicked submit 1. And if you click "submit 2", the output will be You clicked submit 2. That's obvious. But ... what do I need to do to pass the key/value pair "sub" = "submit 3" to the server via POST when I click on the hyperlink showing "submit 3" - so that the output is You clicked submit 3 (i.e. so that $_POST contains "submit 3" referenced to index "sub"). I've tried <a href='javascript: a = {"x" : 1}; document.myform.submit(a);'>submit 3</a>, but that doesn't cause a to be passed via POST. Similar Tutorialswhen i click on submit button, all the data in form will be inserted into my db. but when i click on refresh the form will be submitted again .. how can i prevent this?
I have a problem when submitting through javascript, i have used it hundred times, but i dont know why it refuses to work now, http://two.xthost.info/shailesh/test.htm Please look at the attached file in IE 6 and when you click on "Delete Selected" button, you get javascript error and the form refuses to submit the error is on line document.myform.submit(); I have created a small file where I check if the passwords entered in the code match or not, if they do not match, the button that links to the next webpage should not work(allow them to go to the next wepage). ive tried various websites to help me try and solve this but I just dodont understand what they are doing. I'm very new to programming btw here is some example code: Code: !doctypeHTML <html> <script> //lets just pretend that ive already done all the .getelement by id stuff to get the code things //suppose the person did not write anything in the form, an error will get pushed(alerted basically) if(!form['password'].value) error.push('Missing Password'); <form> <label>Password<br><input type="password" name="password"></label> <label>Confirm Password<br><input type="password" name="confirm"</label> </form> </html> now how would I make the submit button not submit if there are errors? please be as simple as possible, I am new to this! Hello, I have the following DIV tag Code: <div id = "cbContainer"> </div> The div is initially hidden as the display is set to none. I have one text input in my form. Depending upon the changed text in that textbox, there is a javascript function which creates a list of checkboxes and by using the innerHTML, the above div is filled up with the check boxes like shown in the code below: Code: var chkboxes = ''; for(var r = 0; r < related.length; r++) { chkboxes = chkboxes + '<div class ="versionswidth">'+ '<input type="checkbox" name="version" value = related[r] />'+ related[r] + '</div>'; } var div = document.getElementById("cbContainer"); div.innerHTML = chkboxes; div display is then set as "block" which makes the div visible. The problem is that on form submission, the input of selected checkboxes is not submitting. I will be grateful for any help. Thank you. Following are my script to toggle b/w two different links, <html lang="en-US"> <head> <title>toggle b/w 2 different links</title> <script type="text/javascript"><!-- display=1; function displayvalue() { document.getElementById("sv1").style.display = "block"; document.getElementById("dw1").style.display = "none"; } function ShowHide() { if (display==1) { document.getElementById("sv1").style.display = "none"; document.getElementById("dw1").style.display = "block"; //document.getElementById('javaFun') calling java func from javascript display=2; } else { document.getElementById("sv1").style.display = "block"; document.getElementById("dw1").style.display = "none"; //document.getElementById('javaFun1') calling java func from javascript display=1; } } function Func1Delay() { document.getElementById("sv1").style.display = "none"; document.getElementById("loadimage").innerHTML="<input type='image' src='Loading.gif'>"; setTimeout("LoadImage()", 300); } function LoadImage() { document.getElementById("loadimage").innerHTML=""; ShowHide(); } --></script> </head> <body background="GsNJNwuI-UM.gif"onload="displayvalue()"> <div id="sv1" > <a onclick ="Func1Delay()" href="javascript:;">click me</a> </div> <div id="loadimage"></div> <div id="dw1" > <a onclick ="ShowHide()" href="javascript:;">Download me</a> </div> </body> </html> whenever we call a java method , (consider this line:- document.getElementById('javaFun');)after the completion of java call the page is reloading, how control this reloading after the server completing the request....? I'm new to programming, Here's my problem: I'm using a for loop to generate a list of hyperlinks for(i = 100; i < 200; i++) { var str = "link"; document.write(str.link('http://someWebsite.com/' + i +'.html')); document.write("<br />"); } so the list that is generated looks like... link link link ---------and so on until the loop is finished. My question: is it possible for each links text to be dependent on the pages title? for example instead of the the text "link", the program would follow the URL and know in the pages header was the title "Bob's website" or whatever the pages title was and would generate the list. Example: bobs website daves website rons website susies website betsys website ______________________________ Any help to differentiate the links text based on following the URL would be helpful Thank you! I am working with an InDesign CS3 document, with multiple books, and what I want to do is search for a string and turn that string or some how attach an InDesign Hyperlink object to that string. I can find the string using the findText() method var myFoundItems = app.documents.item(0).findText(); And it is returned as a TextStyleRange with its parent being a Story object. What I'm having trouble with is either replacing or attaching a Hyperlink object to string or TextStyleRange. Hyperlink objects to not have a contructor so I don't know how to instantiate a new one and once I get a new one created and the fields populated I don't know how to replace or attach the Hyperlink to that TextStyleRange. I need someone who can help me create javascript code which will create a hyperlink string with a changing variable: This script should write and execute a hyperlink string which opens a separate pop-up window, nothing more. No image files, no subfolders, forget all that stuff. JUST A HYPERLINK. The hyperlink SYNTAX does all the work in loading and selecting the images, NOT THE SCRIPT. There is only one changing variable, the value following clipart_id= Here is the basic hyperlink syntax: <a href="http://www.websitename.com/clipart/manipulate? clipart_id= 00000 &path=%2Fclipart%2Feps%2F&lockRatio=true&width=500&height=500"></a> THERE ARE ALWAYS 2 WINDOWS: ONE WINDOW HOLDS THE HTML; THE OTHER IS A POP-UP WINDOW (The opened hyperlink) The basic html page will contain only 2 objects, an input box and a NEXT BUTTON. Step 1: Initialize the variable from an input box, this variable is used to set the value following clipart_id= which is part of the hyperlink syntax Step 2: The user inputs the initial variable which is used to write the first hyperlink string; click NEXT to launch the first pop-up window Step 3: For each subsequent action Click NEXT - OnClick - This ADDS +1 to the initial variable, this variable is passed to be inserted in a new hyperlink string AND then launches a NEW hyperlink to open a NEW popup window. This is an infinite type of action which advances the value of clipart_id= every time the NEXT button is clicked. Each time you click the NEXT button it advances a counter which executes a NEW hyperlink in a NEW popup window. The only thing that ever changes is the variable after clipart_id=, BUT the entire url syntax of the hyperlink string must be maintained exactly as shown below. If you change the syntax it will not work. So, if the first value to start with is lets say 13000 ; this is input in a box; then the first hyperlink string will automatically be written and open using this: <a href="http://www.websitename.com/clipart/manipulate?clipart_id= 13000 &path=%2Fclipart%2Feps%2F&lockRatio=true&width=500&height=500"></a> Click the NEXT BUTTON and now a new hyperlink window will open which reads like this: <a href="http://www.websitename.com/clipart/manipulate?clipart_id= 13001 &path=%2Fclipart%2Feps%2F&lockRatio=true&width=500&height=500"></a> click the NEXT BUTTON and now a new hyperlink hyperlink window will open reads like this: <a href="http://www.websitename.com/clipart/manipulate?clipart_id= 13002 &path=%2Fclipart%2Feps%2F&lockRatio=true&width=500&height=500"></a> And so on and so on... Nothing else changes. So the "nextpath" after a CLICK is a complete new hyperlink string which contains a vew variable for the value following clipart_id= All I am trying to do is execute a standardized hyperlink string with one changing variable. CAN ANYONE HELP ME TO WRITE THIS CODE? hi there, I'm looking for a method to use several hyperlinks to submit a form and then return the page within the link for example Code: <a href="thispage.php?mode=1" Onclick="javascript:form.submit();"> <a href="thispage.php?mode=2" Onclick="javascript:form.submit();"> the reason for this is so that no matter which link a user navigates to the form will be submitted and no data lost. however the above code obviously loses the POST info as the form action will be different from the a tag. Therefore I think maybe a way of creating a variable that changes the form action to match the a link selected (as the form(s) are submitted to the same php page. hope someone can think clearer than me! cheers I have a requirement where if the page is refreshed or reloaded then one function will be called and if the page is closed some other function will be called. but i can not distinguish between these two events. I have used onbeforeunload and unload event. Please help.
Anyone know how to submit a form and when I press submit, it should simulating the submission of another form, for example let's say Form A, and when I press submit button and submit Form A, it should also automatically submit Form B. Anyone pls help, thanks Hi Guys i have a form on the website http://www.wewilbuyyourcar.ie this is a html form that i need to validate and submit and then show a certain page. I think everything is working except for the js any ideas? This is my form!! Code: <div id="contact_form"> <form id="contact" action="process.php"> <fieldset> <TR><TD><TABLE BORDER="0" CELLPADDING="3" CELLSPACING="0" WIDTH="50%"> <FORM ACTION="" METHOD="post" name="sellcarform" onsubmit="" > <TR><TD CLASS="tableBlueBody" ALIGN="right">* <B>First Name</B></TD><TD CLASS="tableBlueBody" STYLE="border-right : 1px solid #CCCCCC;" ALIGN="left"><INPUT TYPE="Text" NAME="firstname" MAXLENGTH="150"></TD><TD CLASS="tableBlueBody" ALIGN="right">* <B>Last Name</B></TD><TD CLASS="tableBlueBody" ALIGN="center"><INPUT TYPE="Text" NAME="lastname" MAXLENGTH="150"></TD></TR> <TR><TD CLASS="tableBlueBody" ALIGN="right"><B>Address</B></TD><TD CLASS="tableBlueBody" STYLE="border-right : 1px solid #CCCCCC;" ALIGN="left"><INPUT TYPE="Text" NAME="AddressLine1" MAXLENGTH="150"></TD><TD CLASS="tableBlueBody" ALIGN="right">* <B>Email</B></TD><TD CLASS="tableBlueBody" ALIGN="center"><INPUT TYPE="Text" NAME="email" MAXLENGTH="150"></TD></TR> <TR><TD CLASS="tableBlueBody" ALIGN="right"><B>City</B></TD><TD CLASS="tableBlueBody" STYLE="border-right : 1px solid #CCCCCC;" ALIGN="left"><INPUT TYPE="Text" NAME="City" MAXLENGTH="150"></TD><TD CLASS="tableBlueBody" ALIGN="right">* <B>Phone</B></TD><TD CLASS="tableBlueBody" ALIGN="center"><INPUT TYPE="Text" NAME="phone" MAXLENGTH="150"></TD></TR> <TR><TD CLASS="tableBlueBody" ALIGN="right"><B>Country</B></TD><TD CLASS="tableBlueBody" STYLE="border-right : 1px solid #CCCCCC;" ALIGN="left"> <select name="CountryID"> <option value="1" >Albania</option> <option value="2" >Algeria</option> <option value="3" >American Samoa</option> etc... </select> </TD><TD CLASS="tableBlueBody" ALIGN="right"><B>Fax</B></TD><TD CLASS="tableBlueBody" ALIGN="center"><INPUT TYPE="Text" NAME="fax" MAXLENGTH="150"></TD></TR> <TR><TD COLSPAN="4" CLASS="tableBlueBody"> </TD></TR> <TR><TD CLASS="tableBlueBody" ALIGN="right" VALIGN="top"> <B>Comments</B> </TD><TD COLSPAN="3" CLASS="tableBlueBody" ALIGN="left"> <TEXTAREA NAME="comment" ROWS="7" COLS="45" ></TEXTAREA> </TD></TR> </TD><TD COLSPAN="5" CLASS="tableBlueBody" ALIGN="left"> <TR><TD CLASS="tableBlueBody" ALIGN="right">* <B>Registration Number</B></TD><TD CLASS="tableBlueBody" STYLE="border-right : 1px solid #CCCCCC;" ALIGN="left"><INPUT TYPE="Text" NAME="regnumber" MAXLENGTH="150"></TD><TD CLASS="tableBlueBody" ALIGN="right">* <B>Colour</B></TD><TD CLASS="tableBlueBody" ALIGN="center"><INPUT TYPE="Text" NAME="colour" MAXLENGTH="150"></TD></TR> <TR><TD CLASS="tableBlueBody" ALIGN="right">* <B>Car Make</B></TD><TD CLASS="tableBlueBody" STYLE="border-right : 1px solid #CCCCCC;" ALIGN="left"><INPUT TYPE="Text" NAME="carmake" MAXLENGTH="150"></TD><TD CLASS="tableBlueBody" ALIGN="right">* <B>Has the vehicle been used as a taxi?</B></TD><TD CLASS="tableBlueBody" ALIGN="center"><input type='radio' value="Yes" name='question1' /> Yes <input name='question1' type="radio" value="No" checked /> No</TD></TR> <TR><TD CLASS="tableBlueBody" ALIGN="right">* <B>Model</B></TD><TD CLASS="tableBlueBody" STYLE="border-right : 1px solid #CCCCCC;" ALIGN="left"><INPUT TYPE="Text" NAME="model" MAXLENGTH="150"></TD><TD CLASS="tableBlueBody" ALIGN="right">* <B>Is finance outstanding on the vehicle?</B></TD><TD CLASS="tableBlueBody" ALIGN="center"><input type='radio' value="Yes" name='question2' /> Yes <input name='question2' type="radio" value="No" checked /> No</TD></TR> <TR><TD CLASS="tableBlueBody" ALIGN="right">* <B>Milage / Kms</B></TD><TD CLASS="tableBlueBody" STYLE="border-right : 1px solid #CCCCCC;" ALIGN="left"><INPUT TYPE="Text" NAME="milage" MAXLENGTH="150"></TD><TD CLASS="tableBlueBody" ALIGN="right">* <B>How did you hear about us?</B></TD><TD CLASS="tableBlueBody" ALIGN="center"><select name="question3"><option value="Other">Other</option><option value="Web">Web</option><option value="Newspaper">Newspaper</option><option value="Radio">Radio</option><option value="Recommended">Recommended</option></select></TD></TR> <TR><TD COLSPAN="2" CLASS="tableBlueBody" STYLE="border-bottom : 1px solid #CCCCCC; border-right : 1px solid #CCCCCC;"> </TD><TD COLSPAN="2" CLASS="tableBlueBody" STYLE="border-bottom : 1px solid #CCCCCC;"> </TD></TR> <TR><TD COLSPAN="4" ALIGN="left"><input type="submit" value="Click here to send us your information" class='contactFormSubmit'></TD></TR> </FORM></TABLE> </TD></TR></TABLE><BR></TD> <TD><IMG SRC="images/spacer.gif" WIDTH="8" HEIGHT="1" BORDER="0" ALT=""></TD> <TD WIDTH="183" VALIGN="top"> </TD></TR></TABLE> </fieldset> </form><br /> </div><!-- end of #contact_form --> This is my process.php file!! PHP Code: <?php $emailTo = 'sakura-designs@hotmail.com'; $subject = 'We Will Buy Your Car.ie Form Submission'; $firstname=$_POST['firstname']; $lastname=$_POST['lastname']; $email=$_POST['email']; $AddressLine1=$_POST['AddressLine1']; $City=$_POST['City']; $phone=$_POST['phone']; $CountryID=$_POST['CountryID']; $fax=$_POST['fax']; $comment=$_POST['comment']; $regnumber=$_POST['regnumber']; $colour=$_POST['colour']; $carmake=$_POST['carmake']; $question1=$_POST['question1']; $model=$_POST['model']; $question2=$_POST['question2']; $milage=$_POST['milage']; $question3=$_POST['question3']; $body = "First Name: $firstname \n\nLast Name: $lastname \n\nEmail: $email \n\nAddress: $AddressLine1 \n\nCity: $city \n\nPhone: $phone \n\nCountry: $CountryID \n\nFax: $fax \n\nComment: $comment \n\nReg Number: $regnumber \n\nColour: $colour \n\nCar Make: $carmake \n\nQuestion1: $question1 \n\nModel: $model \n\nQuestion2: $question2 \n\nMilage: $milage \n\nQuestion3: $question3"; $headers = 'From: '.$name.' <'.$email.'>' . "\r\n" . 'Reply-To: ' . $email; mail($emailTo, $subject, $body); header( "Location: http://www.wewillbuyyourcar.ie/thankyou.html" ); ?> And this is my contact1.js file!! Code: $(document).ready( function() { $('.error').hide(); $('.but').click( function() { var fname = document.getElementById('firstname'); var lname = document.getElementById('lastname'); var email = document.getElementById('email'); var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/; var AddressLine1 = document.getElementById('AddressLin1'); var city = document.getElementById('city'); var phone = document.getElementById('phone'); var CountryID = document.getElementById('CountryID'); var fax = document.getElementById('fax'); var comment = document.getElementById('comment'); var regnumber = document.getElementById('regnumber'); var colour = document.getElementById('colour'); var carmake = document.getElementById('carmake'); var question1 = document.getElementById('question1'); var model = document.getElementById('model'); var question2 = document.getElementById('question2'); var milage = document.getElementById('milage'); var question3 = document.getElementById('question3'); if(fname.val() != '' && lname.val() != '') { if(email.val() != '' && emailReg.match.exp) { if(comment != '') { $('#comment_error').show(); comment.focus(); return false; } else { var dataString = 'name='+ fname + lname +'&email=' + email + '&comment=' + comment; //alert (dataString);return false; $ajax({ type: "POST", url: "process.php", data: dataString, success: function() { $('#contact_form').html("<div id='message'></div>"); $('#message').html("<strong>Contact Form Submitted!</strong>") .append("<p>We will be in touch soon.</p>") .hide() .fadeIn(1500, function() { jQuery('#message'); }); } }); } } else { $('#email_error').show(); email.focus(); return false; } } else { $('#name_error').show(); fname.focus(); return false; } }); }); Thanks for all your help in advance and Merry Christmas Hi on my site http://bit.ly/dcnrbJ (user:demo, pass:demo) subscribe to newsletter form at the bottom of the page is not working on IE7, any idea what the problem could be? I also get a popup with some error when loading the page.
Sorry I am new to JavaScript. Says that a.html has two same anchor links (<a href="b.html">b</a>). The anchor links are uneditable but we could add JavaScript to the a.html. Except for dynamic adding onclick event, any other ways could get to know which anchor link being clicked? Hi All, I dont know how to display a HTML form when user click on a radio button. I have two forms in a page, when user click on a radio button that correspond to its form, the other form will be hidden. I have the idea to use if...else statement. But I dont know what code to be inserted in an onClick event. I also not sure whether this is logic or not, whether this can be done or not. Pls help me how to accomplish this. I attach the sample of my code here. Thanks in advance. Code: <html> <head> <script type="text/javascript" src="funIndex.js"> </script> </head> <body> <h4>CPI</h4> <!--Choose Single or Multiple Series--> <form name="choose" action="main.html" method="post"> <input type="radio" name="series" value="single" onClick="what code to insert here"/> Single Serie <br/> <input type="radio" name="series" value="multiple" onClick="what code to insert here" /> Multiple Series <br/> </form> <!--To calculate Single Serie--> <script type="text/javascript"> if (document.choose.name.value == "single") { </script> <form name="cpi"> <table border="1"> <tr> <td colspan="2">Single</td> </tr> <tr> <td>Country</td> <td><select name="country"> <option value="Malaysia">Malaysia</option> <option value="Thailand">Thailand</option> <option value="Singapore">Singapore</option> <option value="Indonesia">Indonesia</option> </select> </td> </tr> <tr> <td>Current</td> <td><select name="current" > <option value="1960">1960</option> <option value="1961">1961</option> <option value="1962">1962</option> <option value="1963">1963</option> </select> </td> </tr> <tr> <td>Base</td> <td><select name="base"> <option value="1960">1960</option> <option value="1961">1961</option> <option value="1962">1962</option> <option value="1963">1963</option> </select> </td> </tr> <tr> <td><input type="button" value="Enter" onclick="calIndex(document.cpi.current.options.selectedIndex,document.cpi.base.options.selectedIndex)"> </td> </tr> <tr> <td>Index</td> <td><input type="text" name="idx" id="idx2" /></td> </tr> </table> </form> <!--To calculate multiple series--> <script type="text/javascript"> } else if (document.choose.name.value == "multiple") { </script> <form name="cpi2"> <table border="1"> <tr> <td colspan="2">Multiple</td> </tr> <tr> <td>Country</td> <td><select name="country"> <option value="Malaysia">Malaysia</option> <option value="Thailand">Thailand</option> <option value="Singapore">Singapore</option> <option value="Indonesia">Indonesia</option> </select> </td> </tr> <tr> <td>Current From</td> <td><select name="current" > <option value="1960">1960</option> <option value="1961">1961</option> <option value="1962">1962</option> <option value="1963">1963</option> </select> </td> </tr> <tr> <td>Current To</td> <td><select name="current" > <option value="1960">1960</option> <option value="1961">1961</option> <option value="1962">1962</option> <option value="1963">1963</option> </select> </td> </tr> <tr> <td>Base</td> <td><select name="base"> <option value="1960">1960</option> <option value="1961">1961</option> <option value="1962">1962</option> <option value="1963">1963</option> </select> </td> </tr> <tr> <td><input type="button" value="Enter" > </td> </tr> </table> </form> <script type="text/javascript"> } </script> </body> </html> Can anyone tell why IE does not handle this form submit properly? Instead of going to the action of the form in formString, it just refreshes the page. Works fine in Firefox and Chrome. Code: Here is how the form is placed on the page and then submitted: document.getElementById('crtDiv').innerHTML = formString; document.getElementById('crtForm').submit(); Here is an example of how the formString is built: formString = "<form action='https://www.paypal.com/cgi-bin/webscr' method='POST' id='crtForm'>"; formString += BUNCH O INPUTS formString += "</form>"; The thing i want to do If any field is empty -->User will see a message to fill out the field When both field is filled out and press Submit button --> goes to thankyou.php page <html> <head></head> <body> <?php $fname = $_POST['fname']; $lname = $_POST['lname']; ?> <form action="thankyou.php" method="POST"> First Name: <input type="text" name='fname'/> <?php if(empty($fname)) echo "Please provide your First Name";?><br/> Last Name: <input type="text" name='lname'/> <?php if(empty($lname)) echo "Please provide your Last Name";?><br/> <input type="submit" value="submit" /><input type="reset" value="Clear Form"/> </form> </body> </html> thankyou.php <?php echo "Thank you $fname $lname for your time." ?> I am having trouble submitting a form after validation. Here is my script. The validation works fine its just that after the form does not submit. Code: <script language='javascript'> function verifyMe(){ var msg=''; if(document.getElementById('company').value==''){ msg+='- Company Name\n\n';} if(document.getElementById('contact').value==''){ msg+='- Contact Name / Job Title\n\n';} if(document.getElementById('address').value==''){ msg+='- Trading Address\n\n';} if(document.getElementById('postcode').value==''){ msg+='- Postcode\n\n';} if(document.getElementById('telephone').value==''){ msg+='- Telephone\n\n';} if(document.getElementById('mobile').value==''){ msg+='- Mobile\n\n';} var email=document.getElementById('email').value; if(!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email))){ msg+='- Invalid Email Address: '+email+'\n\n';} if(document.getElementById('email').value==''){ msg+='- Email\n\n';} if(document.getElementById('employees').value==''){ msg+='- Number of Full-Time equivalent employees\n\n';} if(document.getElementById('turnover').value==''){ msg+='- Annual Turnover\n\n';} if(document.getElementById('assetvalue').value==''){ msg+='- Total asset value\n\n';} if(!document.getElementById('sme[0]').checked && !document.getElementById('sme[1]').checked){ msg+='- Is more than 25% of your company owned by an enterprise which is not itself an SME?\n\n';} if(document.getElementById('tradetime').value==''){ msg+='- How many months has your company been trading?\n\n';} if(document.getElementById('nature').value==''){ msg+='- Nature of Business Sector\n\n';} if(document.getElementById('typeofo').value==''){ msg+='- Type of Organisation\n\n';} if(document.getElementById('companyregisteredname').value==''){ msg+='- Company Registered Name\n\n';} if(document.getElementById('regnumber').value==''){ msg+='- Registration Number\n\n';} if(document.getElementById('vatreg').value==''){ msg+='- VAT Reg Number\n\n';} if(document.getElementById('regaddress').value==''){ msg+='- Registered Address\n\n';} if(document.getElementById('catapply').value==''){ msg+='- Which Catagories Apply?\n\n';} if(document.getElementById('fuelused').value==''){ msg+='- Current fuel used\n\n';} if(document.getElementById('otherfuel').value==''){ msg+='- Other (if applicable)\n\n';} if(document.getElementById('heatingpercent').value==''){ msg+='- What percentage of this is used for heating?\n\n';} if(document.getElementById('factoryspaceheating').value==''){ msg+='- Factory Space Heating\n\n';} if(document.getElementById('officeheating').value==''){ msg+='- Office Heating\n\n';} if(document.getElementById('hotwater').value==''){ msg+='- Hot Water\n\n';} if(document.getElementById('heaterrating').value==''){ msg+='- Combine Rating of Existing Heaters\n\n';} if(document.getElementById('existingheaters').value==''){ msg+='- Number of existing heaters\n\n';} if(document.getElementById('setbackheating').value==''){ msg+='- Is night set back heating employed?\n\n';} if(document.getElementById('billavalable').value==''){ msg+='- Are they avalable?\n\n';} if(document.getElementById('factorysize').value==''){ msg+='- Factory Size\n\n';} if(document.getElementById('roofheighte').value==''){ msg+='- Roof Height to Eaves\n\n';} if(document.getElementById('roofheightr').value==''){ msg+='- Roof Height to Ridge\n\n';} if(document.getElementById('builddate').value==''){ msg+='- Approx. Date building was built\n\n';} if(document.getElementById('spraybooths').value==''){ msg+='- Spray Booths?\n\n';} if(document.getElementById('dustextract').value==''){ msg+='- Dust Extraction\n\n';} if(document.getElementById('air').value==''){ msg+='- Is the air returned to the building?\n\n';} if(document.getElementById('rollershutters').value==''){ msg+='- Roller Shutters?\n\n';} if(document.getElementById('weekoc').value==''){ msg+='- Weekly building occupancy\n\n';} if(document.getElementById('occupancy').value==''){ msg+='- Daily Building Occupancy\n\n';} if(document.getElementById('woodwaste').value==''){ msg+='- Type of wood waste\n\n';} if(document.getElementById('woodavailable').value==''){ msg+='- Quantity available per wek\n\n';} if(document.getElementById('upload').value==''){ msg+='- Upload bills here.\n\n';} if(msg!=''){ alert('The following fields are empty or invalid:\n\n'+msg); return false }else{ document.carbonform.submit(); return true } } </script> <html> <head> <link href="style.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="stylized" class="myform"> <form name='carbonform' action="process.php" method='POST' enctype='application/x-www-form-urlencoded' onsubmit='return verifyMe();'> <table class='table_form_1' id='table_form_1' cellspacing='0'> <h1>Carbon Trust Application Form.</h1> <p>Please make sure you enter all fields marked with an <b style='color:red'>*</b>. If you submit an incomplete form we cannot help you.</p> <tr> <td class='ftbl_row_1' ><LABEL for='company' ACCESSKEY='none' ><b style='color:red'>*</b>Company Name </td> <td class='ftbl_row_1a' ><input type='text' name='company' id='company' size='45' maxlength='150' value=''> </td> </tr> <tr> <td class='ftbl_row_2' ><LABEL for='contact' ACCESSKEY='none' ><b style='color:red'>*</b>Contact Name / Job Title </td> <td class='ftbl_row_2a' ><input type='text' name='contact' id='contact' size='45' maxlength='150' value=''> </td> </tr> <tr> <td valign='top' class='ftbl_row_1' ><LABEL for='address' ACCESSKEY='none' ><b style='color:red'>*</b>Trading Address </td> <td class='ftbl_row_1a' ><textarea name='address' id='address' cols='35' rows='6' value=''></textarea> </td> </tr> <tr> <td class='ftbl_row_2' ><LABEL for='postcode' ACCESSKEY='none' ><b style='color:red'>*</b>Postcode </td> <td class='ftbl_row_2a' ><input type='text' name='postcode' id='postcode' size='45' maxlength='10' value=''> </td> </tr> <tr> <td class='ftbl_row_1' ><LABEL for='telephone' ACCESSKEY='none' ><b style='color:red'>*</b>Telephone </td> <td class='ftbl_row_1a' ><input type='text' name='telephone' id='telephone' size='45' maxlength='30' value=''> </td> </tr> <tr> <td class='ftbl_row_2' ><LABEL for='mobile' ACCESSKEY='none' ><b style='color:red'>*</b>Mobile </td> <td class='ftbl_row_2a' ><input type='text' name='mobile' id='mobile' size='45' maxlength='20' value=''> </td> </tr> <tr> <td class='ftbl_row_1' ><LABEL for='email' ACCESSKEY='none' ><b style='color:red'>*</b>Email </td> <td class='ftbl_row_1a' ><input type='text' name='email' id='email' size='45' maxlength='50' value=''> </td> </tr> <tr> <td class='ftbl_row_2' ><LABEL for='employees' ACCESSKEY='none' ><b style='color:red'>*</b>Number of Full-Time equivalent employees </td> <td class='ftbl_row_2a' ><input type='text' name='employees' id='employees' size='45' maxlength='8' value=''> </td> </tr> <tr> <td class='ftbl_row_1' ><LABEL for='turnover' ACCESSKEY='none' ><b style='color:red'>*</b>Annual Turnover </td> <td class='ftbl_row_1a' ><input type='text' name='turnover' id='turnover' size='45' maxlength='20' value=''> </td> </tr> <tr> <td class='ftbl_row_2' ><LABEL for='assetvalue' ACCESSKEY='none' ><b style='color:red'>*</b>Total asset value </td> <td class='ftbl_row_2a' ><input type='text' name='assetvalue' id='assetvalue' size='45' maxlength='20' value=''> </td> </tr> <tr> <td class='ftbl_row_1' ><b style='color:red'>*</b>Is more than 25% of your company owned by an enterprise which is not itself an SME? </td> <td class='ftbl_row_1a' > <LABEL ACCESSKEY='1'><input type='checkbox' name='sme' id='sme[0]' value='Yes'>Yes</LABEL> <LABEL ACCESSKEY='2'><input type='checkbox' name='sme' id='sme[1]' value='No' CHECKED >No</LABEL> </td> </tr> <tr> <td class='ftbl_row_2' ><LABEL for='tradetime' ACCESSKEY='none' ><b style='color:red'>*</b>How many months has your company been trading? </td> <td class='ftbl_row_2a' ><input type='text' name='tradetime' id='tradetime' size='45' maxlength='5' value=''> </td> </tr> <tr> <td class='ftbl_row_1' ><LABEL for='nature' ACCESSKEY='none' ><b style='color:red'>*</b>Nature of Business Sector </td> <td class='ftbl_row_1a' ><input type='text' name='nature' id='nature' size='45' maxlength='50' value=''> </td> </tr> <tr> <td class='ftbl_row_2' ><LABEL for='typeofo' ACCESSKEY='none' ><b style='color:red'>*</b>Type of Organisation </td> <td class='ftbl_row_2a' ><select name='typeofo' id='typeofo'> <option value='Public'>Public</option> <option value='Private'>Private</option> <option value='Charity'>Charity</option> <option value='Limited / Sole Trader'>Limited / Sole Trader</option> </select> </td> </tr> <tr> <td class='ftbl_row_1' ><LABEL for='companyregisteredname' ACCESSKEY='none' ><b style='color:red'>*</b>Company Registered Name </td> <td class='ftbl_row_1a' ><input type='text' name='companyregisteredname' id='companyregisteredname' size='45' maxlength='150' value=''> </td> </tr> <tr> <td class='ftbl_row_2' ><LABEL for='regnumber' ACCESSKEY='none' ><b style='color:red'>*</b>Registration Number </td> <td class='ftbl_row_2a' ><input type='text' name='regnumber' id='regnumber' size='45' maxlength='10' value=''> </td> </tr> <tr> <td class='ftbl_row_1' ><LABEL for='vatreg' ACCESSKEY='none' ><b style='color:red'>*</b>VAT Reg Number </td> <td class='ftbl_row_1a' ><input type='text' name='vatreg' id='vatreg' size='45' maxlength='15' value=''> </td> </tr> <tr> <td valign='top' class='ftbl_row_2' ><LABEL for='regaddress' ACCESSKEY='none' ><b style='color:red'>*</b>Registered Address </td> <td class='ftbl_row_2a' ><textarea name='regaddress' id='regaddress' cols='35' rows='6' value=''></textarea> </td> </tr> <tr> <td class='ftbl_row_1' ><LABEL for='catapply' ACCESSKEY='none' ><b style='color:red'>*</b>Which Catagories Apply? </td> <td class='ftbl_row_1a' ><select name='catapply' id='catapply'> <option value='Space Heating'>Space Heating</option> <option value=' Process Heating'> Process Heating</option> </select> </td> </tr> <tr> <td class='ftbl_row_2' ><LABEL for='fuelused' ACCESSKEY='none' ><b style='color:red'>*</b>Current fuel used </td> <td class='ftbl_row_2a' ><select name='fuelused' id='fuelused'> <option value='Gas'>Gas</option> <option value='Oil'>Oil</option> <option value='Other'>Other</option> </select> </td> </tr> <tr> <td class='ftbl_row_1' ><LABEL for='otherfuel' ACCESSKEY='none' ><b style='color:red'>*</b>Other (if applicable) </td> <td class='ftbl_row_1a' ><input type='text' name='otherfuel' id='otherfuel' size='45' maxlength='30' value=''> </td> </tr> <tr> <td class='ftbl_row_2' ><LABEL for='heatingpercent' ACCESSKEY='none' ><b style='color:red'>*</b>What percentage of this is used for heating? </td> <td class='ftbl_row_2a' ><input type='text' name='heatingpercent' id='heatingpercent' size='45' maxlength='3' value=''> </td> </tr> <tr> <td class='ftbl_row_1' ><LABEL for='factoryspaceheating' ACCESSKEY='none' ><b style='color:red'>*</b>Factory Space Heating </td> <td class='ftbl_row_1a' ><input type='text' name='factoryspaceheating' id='factoryspaceheating' size='45' maxlength='100' value=''> </td> </tr> <tr> <td class='ftbl_row_2' ><LABEL for='officeheating' ACCESSKEY='none' ><b style='color:red'>*</b>Office Heating </td> <td class='ftbl_row_2a' ><input type='text' name='officeheating' id='officeheating' size='45' maxlength='3' value=''> </td> </tr> <tr> <td class='ftbl_row_1' ><LABEL for='hotwater' ACCESSKEY='none' ><b style='color:red'>*</b>Hot Water </td> <td class='ftbl_row_1a' ><input type='text' name='hotwater' id='hotwater' size='45' maxlength='3' value=''> </td> </tr> <tr> <td class='ftbl_row_2' ><LABEL for='heaterrating' ACCESSKEY='none' ><b style='color:red'>*</b>Combine Rating of Existing Heaters </td> <td class='ftbl_row_2a' ><input type='text' name='heaterrating' id='heaterrating' size='45' maxlength='10' value=''> </td> </tr> <tr> <td class='ftbl_row_1' ><LABEL for='existingheaters' ACCESSKEY='none' ><b style='color:red'>*</b>Number of existing heaters </td> <td class='ftbl_row_1a' ><input type='text' name='existingheaters' id='existingheaters' size='45' maxlength='4' value=''> </td> </tr> <tr> <td class='ftbl_row_2' ><LABEL for='setbackheating' ACCESSKEY='none' ><b style='color:red'>*</b>Is night set back heating employed? </td> <td class='ftbl_row_2a' ><select name='setbackheating' id='setbackheating'> <option value='Yes'>Yes</option> <option value='No'>No</option> </select> </td> </tr> <tr> <td class='ftbl_row_1' ><LABEL for='billavalable' ACCESSKEY='none' ><b style='color:red'>*</b>Are they avalable? </td> <td class='ftbl_row_1a' ><select name='billavalable' id='billavalable'> <option value='Yes'>Yes</option> <option value='No'>No</option> </select> </td> </tr> <tr> <td class='ftbl_row_2' ><LABEL for='factorysize' ACCESSKEY='none' ><b style='color:red'>*</b>Factory Size </td> <td class='ftbl_row_2a' ><input type='text' name='factorysize' id='factorysize' size='45' maxlength='60' value=''> </td> </tr> <tr> <td class='ftbl_row_1' ><LABEL for='roofheighte' ACCESSKEY='none' ><b style='color:red'>*</b>Roof Height to Eaves </td> <td class='ftbl_row_1a' ><input type='text' name='roofheighte' id='roofheighte' size='45' maxlength='10' value=''> </td> </tr> <tr> <td class='ftbl_row_2' ><LABEL for='roofheightr' ACCESSKEY='none' ><b style='color:red'>*</b>Roof Height to Ridge </td> <td class='ftbl_row_2a' ><input type='text' name='roofheightr' id='roofheightr' size='45' maxlength='10' value=''> </td> </tr> <tr> <td class='ftbl_row_1' ><LABEL for='builddate' ACCESSKEY='none' ><b style='color:red'>*</b>Approx. Date building was built </td> <td class='ftbl_row_1a' ><input type='text' name='builddate' id='builddate' size='45' maxlength='10' value=''> </td> </tr> <tr> <td class='ftbl_row_2' ><LABEL for='spraybooths' ACCESSKEY='none' ><b style='color:red'>*</b>Spray Booths? </td> <td class='ftbl_row_2a' ><select name='spraybooths' id='spraybooths'> <option value='Yes'>Yes</option> <option value='No'>No</option> </select> </td> </tr> <tr> <td class='ftbl_row_1' ><LABEL for='dustextract' ACCESSKEY='none' ><b style='color:red'>*</b>Dust Extraction </td> <td class='ftbl_row_1a' ><select name='dustextract' id='dustextract'> <option value='Yes'>Yes</option> <option value='No'>No</option> </select> </td> </tr> <tr> <td class='ftbl_row_2' ><LABEL for='air' ACCESSKEY='none' ><b style='color:red'>*</b>Is the air returned to the building? </td> <td class='ftbl_row_2a' ><select name='air' id='air'> <option value='Yes'>Yes</option> <option value='No'>No</option> </select> </td> </tr> <tr> <td class='ftbl_row_1' ><LABEL for='rollershutters' ACCESSKEY='none' ><b style='color:red'>*</b>Roller Shutters? </td> <td class='ftbl_row_1a' ><select name='rollershutters' id='rollershutters'> <option value='Yes'>Yes</option> <option value='No'>No</option> </select> </td> </tr> <tr> <td class='ftbl_row_2' ><LABEL for='weekoc' ACCESSKEY='none' ><b style='color:red'>*</b>Weekly building occupancy </td> <td class='ftbl_row_2a' ><input type='text' name='weekoc' id='weekoc' size='45' maxlength='10' value=''> </td> </tr> <tr> <td class='ftbl_row_1' ><LABEL for='occupancy' ACCESSKEY='none' ><b style='color:red'>*</b>Daily Building Occupancy </td> <td class='ftbl_row_1a' ><input type='text' name='occupancy' id='occupancy' size='45' maxlength='5' value=''> </td> </tr> <tr> <td class='ftbl_row_2' ><LABEL for='woodwaste' ACCESSKEY='none' ><b style='color:red'>*</b>Type of wood waste </td> <td class='ftbl_row_2a' ><input type='text' name='woodwaste' id='woodwaste' size='45' maxlength='30' value=''> </td> </tr> <tr> <td class='ftbl_row_1' ><LABEL for='woodavailable' ACCESSKEY='none' ><b style='color:red'>*</b>Quantity available per wek </td> <td class='ftbl_row_1a' ><input type='text' name='woodavailable' id='woodavailable' size='45' maxlength='20' value=''> </td> </tr> <tr> <td class='ftbl_row_2' ><LABEL for='upload' ACCESSKEY='none' ><b style='color:red'>*</b>Upload bills here. </td> <td class='ftbl_row_2a' ><input type='file' name='upload' id='upload' size='100' value=''> </td> </tr> <tr> <td colspan='2' align='right'><input type='submit' name='submit' value='Submit' onclick="function verifyMe()" > <input type='reset' name='reset' value='Reset'><br /><a href='http://www.Jaynetdesign.com.com' style='font-family:arial;font-size:10px;color:#C0C0C0;text-decoration:none'>Created by James Eley</a> </td> </tr> </table> </form> </div> </body> </HTML> Key info is on lines: 138 - 152 Code: if(msg!=''){ alert('The following fields are empty or invalid:\n\n'+msg); return false }else{ document.carbonform.submit(); return true } } Code: <form name='carbonform' action="process.php" method='POST' enctype='application/x-www-form-urlencoded' onsubmit='return verifyMe();'> and 441. Code: <td colspan='2' align='right'><input type='submit' name='submit' value='Submit' onclick="function verifyMe()" > <input type='reset' name='reset' value='Reset'> My php script just contains an echo to test. Thanks in advance. Hi there, I am trying to automatically submit a form in an iframe with javascript. My question is whether this is possible or not, and if so how the code should look like to submit the form in the iframe? this is the form within the iframe that I am trying to submit automatically: Code: <form id="Form2051051" action="nieuw-bericht.2051051.lynkx" method="post" class="form" onsubmit="return ProcessForm( 'Form2051051' );"> <div> <a href="#" onclick="document.getElementById( 'event' ).value='Step1'; document.getElementById( 'Form2051051' ).submit(); return false;" class="button previous"><span>Wijzig</span></a> <a href="#" onclick="if ( ProcessForm( 'Form2051051' ) ) document.getElementById( 'Form2051051' ).submit(); return false;" class="button next-long"><span>Plaats bericht</span></a> </div> <input type="hidden" id="event" name="event" value="Confirmed-Step3" /> <input type="hidden" name="PostedField[_berichtId]" value="" /> <input type="hidden" name="formState" value="KQAAAAoAAAEAAgADAAQABQA9taWULZGFzZGFzIHNhZGEA" /> </form> this is what I have tried so far: Code: <body LANGUAGE="javascript" onload="window.frames['myframe'].document.getElementById( 'Form2051051' ).submit();"> <iframe name="myframe" id="frame1" src="link-to-the-page-with-the-form"> </iframe> </body> It might be worth to mention that the webpage within the iframe is from an external website (im not in control of it). I am not sure if it's possible to use javascript on an external website in an iframe? I am pretty new with this so I appreciate any help or suggestions! thank you hello .. i have some problem while while working on a script.. i want to use confirmation() function to confirm submit button and if its true ...then submit form... else keep on same page (thats logic) am using php as server scripting .. and i wrote ..in php PHP Code: <form action="del_cat.php\" name=\"myform\" method=\"post\"> "; Delete: <input type="submit\" name=\"delete\" onclick=\"confirmation()\" value=\"Delete\" > <br> Edit:<input type=\"submit\" name=\"edit\" value=\"Edit\" > </form>"; and used a javascript in head PHP Code: <script type="text/javascript\"> function confirmation() { var r=confirm(\"Are you ready to delete?\"); if (r==true) { document.myform.submit(); } else { alert(\"check twise before submitting \") } } </script> my problem is if i click "OK" or "Cancel" both case the form is automatically submitting ... see i used PHP Code: if (isset($_POST['delete'])) { mysql_query("DELETE FROM ********* WHERE id='{$_POST['cid']}'"); } this code to invoke the function .. |