Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    May 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Auto submit form in a bookmarklet

    Hi

    I'm trying to create a bloging bookmarklet for use with my geeklog site.
    I have it functioning with a popup window that shows the content to send and allows for modifications, and there is a submit button that sends it to the blogs php script. The php script accepts the data and your left at the preview story screen, essentially the same thing as the popup i'm triggering.

    I would like to remove the first "verification" stage, and just have the form autosubmit and popup the php script in a new window.

    this is what i'm using now unwrapped...to do the bookmarklet it has to be one continuous line of code, to make things easier to view I formated it here
    Code:
    javascript:
    u=document.location.href;
    var t=document.title;
    sr=window.getSelection();
    var f='width=600,height=600,toolbar=0,location=0,directories=0,status=1,menuBar=0,scrollBars=1,resizable=1';
    var s=window.open('','Title',f);with(s.document){write('
    	<html><title>geekloglette</title>
    	<body style=margin: 0px 0px 0px 0px;background-color:#FFCC00>
    	<form action=%22http://SITE.URL/PATH_TO_GEEKLOG_ROOT/submit.php%22 method=%22post%22>
    		<table border=%220%22 cellspacing=%220%22 cellpadding=%223%22>
    			<tr>
    				<td align=%22right%22>
    				<b>Title:</b>
    				</td>
    				<td>
    				<input type=%22text%22 size=%2236%22 maxlength=%2296%22 name=%22title%22 value='+t+'>
    				</td>
    			</tr>
    			<tr>
    				<td align=%22right%22>
    				<b>Topic:</b>
    				</td>
    				<td>
    					<select name=tid>
    					<option value=%22TOPIC1%22>TOPIC1</option>
    					<option value=%22TOPIC2%22>TOPIC2</option>
    					<option value=%22TOPIC3%22>TOPIC3</option>
    					</select>
    				</td>
    			</tr>
    			<tr valign=%22top%22>
    				<td align=%22right%22>
    				<b>Story:</b>
    				</td>
    				<td>
    					<textarea name=%22introtext%22 cols=%2245%22 rows=%2212%22 wrap=%22virtual%22>'+sr+'<BR><a href=%22'+u+'%22 target=_blank>'+t+'</a>
    					</textarea>
    				</td>
    			</tr>
    			<tr valign=%22top%22>
    				<td align=%22right%22>
    				<b>Post Mode:</b>
    				</td>
    				<td>
    					<select name=%22postmode%22>
    					<option value=%22html%22 selected=%22selected%22>HTML </option>
    					</select>
    					<br>
    				</td>
    			</tr>
    			<tr>
    				<td align=%22center%22 colspan=%222%22>
    				<input type=%22hidden%22 name=%22type%22 value=story>
    				<input type=%22hidden%22 name=%22uid%22 value=%222%22>
    				<input type=%22hidden%22 name=%22date%22 value=%22%22>
    				<input name=%22mode%22 type=%22submit%22 value=%22Preview%22>
    				</td>
    			</tr>
    		</table>
    	</form>
    	</body>
    	</html>');
    void(close())}
    i've tried naming the form "form" and adding this function
    Code:
     function submitForm(){
    document.form.submit();
    }
    and calling it from the body with onload=

    and i've tried reading in the data before the body call with a function like this

    Code:
    function autoSubmit ()
    {
    document.Form.title.value = '+t+';
    document.Form.introtext.value = '+sr+';
    
    document.Form.submit();
    }
    
    <body onLoad="autoSubmit();">
    <form name="Form" action="site.url/submit.php">
    <input type="title" value= "" />
    <input type="introtextt" value= "" />
    </form>
    </body>
    neither of these worked...the first one had no effect at all, and the second one doesn't seem to peform the action call.

    any ideas?
    i'm kinda stuck....

  • #2
    Regular Coder
    Join Date
    Feb 2005
    Posts
    400
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I suspect that your problems with onload not working are due to not closing the document -- document.write(...) should be followed by document.close() when creating a document from scratch.

    This barebones version worked for me in Firefox:
    Code:
    javascript:(function(){var w=window,t=document.title,x=w.open().document;x.write("<html><body onload='document.f.submit()'><form name='f' action='http://labapache:8080/blogtest.php' method='post'><input name='title' value='"+t+"'><textarea name='introtext'>"+w.getSelection()+"<br><a href='"+w.location+"' target=_blank>"+t+"</a></textarea><input type='hidden' name='type' value='story'><input type='hidden' name='uid' value='2'><input type='hidden' name='date' value=''><input name='mode' type='submit' value='Preview'></form></body></html>");x.close()})()

  • #3
    New to the CF scene
    Join Date
    May 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanx
    that helped alot
    i went thru and restructured things, and it turns out i was forgetting to pass one variable over so the php in my blog it was coming up blank.
    got it working now tho, thanx again.

    now i'm going to try and get this to work in a firefox extension
    cheers


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •