I am trying to use an image to submit a form on my page. Here is the code I currently have, that works:
<form name="regForm" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" id="regForm" >
....input form here....
<input name="doRegister" type="submit" id="doRegister" value="Register">
</form>
What I am attempting to use, that does not work:
<form name="doRegister" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" id="doRegister">
....input form here....
<input type="image" value="Register" src="../register.png" style="vertical-align: middle; height: 30px; width: 66px;" onsubmit="submit-form();" />
When clicking the button to submit, it reloads the page, without actually submitting the data.
Is this a Post v Get issue?
I also had this trouble in the past when doing something like this, try <input type="image" src="../register.png" alt="Register" name="doRegister" />
and in php use $_POST['x_doRegister'] (the x_ might not be needed)
Related
I need to write xpath for 'New' button.
have tried:-
By.xpath("//form[#action='/intruvert/action/CustomRolesAction']/div/div[3]/div/a[1]")
By.xpath("//form[#name='CustomRolesForm']/div/div[3]/div/a[#style='background-color: rgb(242, 242, 242);' and #title='New']")
By.xpath("//form[#name='CustomRolesForm']/div/div[3]/div/a[#title='New']")
but not able to click on New button.
I am not sure here if i missing anything.
kindly suggest.
here is the code:-
<html>
<head>
<body>
<div class="bodywrap">
<form action="/intruvert/action/CustomRolesAction" method="post" name="CustomRolesForm">
<input type="hidden" value="CustomRolesDetails_t" name="userAction"/>
<input type="hidden" value="fullaccess" name="accessRight"/>
<input type="hidden" value="" name="uuid"/>
<input type="hidden" value="true" name="fromTab"/>
<input type="hidden" value="" name="selectedDomain"/>
<input type="hidden" value="/My Company:0/Manager:0" name="resourceName"/>
<input type="hidden" value="MANAGER" name="topMenuName"/>
<input type="hidden" value="Users and Roles" name="secondMenuName"/>
<input type="hidden" value="Roles" name="thirdMenuName"/>
<input type="hidden" value="/My Company:0" name="domainName"/>
<input type="hidden" value="/My Company:0" name="currentDomainName"/>
<input type="hidden" value="/Manager:0" name="shortResourceName"/>
<input type="hidden" value="false" name="ucaplModeEnabled"/>
<table width="100%" cellspacing="0" cellpadding="0" border="0" align="center">
<div class="gensecholder clearfix">
<div class="gensecheader clearfix">
<div class="gensecbody pad10all clearfix">
<div class="gensecfooter clearfix">
<div class="gensecfootright">
<a class="genericbtn" title="New" href="javascript:doSubmit('add')">New</a>
</div>
#Pranay after viewing your code, i got javascript error. inside your html you have not defined anywhere to javascript. see the image
Your html
<a class="genericbtn" title="New" href="javascript:doSubmit('add')">New</a>
Modified html
<a class="genericbtn" title="New" href="#">New</a>
Now use xpath method using javascript executor.
WebElement new_button = driver.findElement(By.xpath("//a[contains(text(), 'New')]"));
((JavascriptExecutor) driver).executeScript("arguments[0].click();", new_button);
OR
driver.findElement(By.xpath("//a[contains(text(), 'New')]")).click();
You can try to locate the button directly without ancestors
// by class name
By.className("genericbtn")
// by title
By.cssSelector("[title='New']")
// by partial href
By.cssSelector("[href*='add']")
//a[.="New"]
Just use text find a tag.
. means current context node(a).
You can just use either title or text property to find out the required link:
By.xpath("//a[#title='New']");
Or
By.linkText("New");
Or
By.xpath("//a[text()='New']");
I am trying to use CKeditor plugin as HTML text editor. But the problem is if I have an input type="file" then when I submit the ckeditor plugin doesn't post the text I wrote inside it. But If I remove the input type="file" from my form then it works fine.
I need to have both in my form. Could you please tell me how to get both work fine?
Thanks
<script language="JavaScript" src="<?php echo base_url();?>support_admin/plugins/ckeditor/ckeditor.js" type="text/javascript"></script>
<form action="something">
<label>Details</label>
<textarea class="ckeditor" name="article" ><?php echo $articles; ?></textarea><br>
<label>Image 1</label>
<input type="file" name="imagefile1" /><br>
<button class="button" style="margin-left: 200px;">Submit</button>
</form>
I'm having an issue where the form generated with ruby isn't included inside my #content div, is this because the form is generated after the html is read by the browser (sorry if I sound like a moron on this)
-- edit update - view source --
The code below generates with the email box and submit button outside of the content box
<div id="content">
<!-- text here -->
<form accept-charset="UTF-8" action="/password_resets" method="post">
<div style="margin:0;padding:0;display:inline">
<input name="utf8" type="hidden" value="✓" />
<input name="authenticity_token" type="hidden" value="afmtpSAc93w1uMcnouhY9XmbVTM7fE1VNFvZKnp0kMs=" />
</div>
<div class="field">
<input id="email" name="email" placeholder="email#website.com" type="text" />
</div>
<div class="actions">
<input name="commit" type="submit" value="Reset Password" />
</form> </div>
</div>
I'm not sure I got the question right, but in the html above the last </form> </div> should be </div> </form>
figured it out after visiting this link
Is it correct to use DIV inside FORM?
once I removed the div's for field and action it cleared everything up
I have a simple form with a submit button. I would like to use the submit button using an image something like,
<INPUT TYPE="image" SRC="images/submit.gif" HEIGHT="30" WIDTH="173" BORDER="0" ALT="Submit Form">
How can I use the image as submit button? Then what I want to change in jquery initialisation?
<form action='#' id='freeForm' method='post' autocomplete="off">
<a>
<input style='border: none' type='submit' value='Submit' />
</a>
</form>
jQuery
$("#freeForm").submit(function()
{
});
Thanks!
jQuery isn't necessary, as an image button already submits a form.
<form>
<input type="image" src="foo.png" />
</form>
Fiddle: http://jsfiddle.net/jonathansampson/AkR95/
u can do some thing like this
$("#image").onclick(function()
{
$("#freeForm").submit();
});
#image is the id of element containing your image.
Try this one:
<input type="submit" value="Enter" name="submit" style="background:url('/imgBG.jpg') no-repeat;width:100;height:50;border:none;"/>
I have a form that is served via Ajax from the server when a button is clicked. It pops up in a jquery dialog.
<form onsubmit="hideModal();return getAJAX(this);">
<input type="hidden" name="action" value="updateUserNotes">
<input type="hidden" name="userid" value="20312">
<hr/>
<B>Flags:</B><BR/>
<input type="radio" name="flag" value="none" checked> <img src="images/icons/grey_flag.png"> No Flag<BR>
<input type="radio" name="flag" value="green" > <img src="images/icons/flag_green.png"> Green Flag<BR>
<input type="radio" name="flag" value="red" > <img src="images/icons/flag_red.png"> Red Flag
<B>NOTES:</B><BR>
<textarea name="usernotes" cols="80" rows="10"></textarea>
<input type="submit" value="Save Notes">
</form>
This is the code that my script sends back to display the form. With the HR in there, the form will not submit when you click "save notes". It does not throw a javascript error, it simply does not submit.
If I remove the horizontal rule the form submits 100% fine.
Anyone know what might be causing this? It only appears to affect IE9. I cannot replicate it in Chrome or Firefox or earlier versions of IE9.
I think it has something to do with IE9's strictness, but I can't figure out how the horizontal rule is messing anything up.