Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Dumb javascript form question

Options
  • 23-11-2012 10:31pm
    #1
    Registered Users Posts: 19,309 ✭✭✭✭


    I'm trying to set up an uploadthingy image submission form, but have run up against a problem with the javascript (knowledge=zilch). I'm fine with the standard text fields in the form, but I'd like to have a dropdown form, and a either/or radio button option in there too. I've rigged up a test page with operational text fields, but a non-working dropdown:

    http://www.hexhibit.com/Archive-test-2/test-form.html

    The code for the pulldown was butchered from a different form, and I've done a half-assed job of trying to crowbar it in to this, but without success - can anyone point me in the right direction? Here's the code:
    <script src="http://49video.resources.s3.amazonaws.com/uploadthingy.js" type="text/javascript" language="Javascript"></script>
    <iframe id="uploadtarget" name="uploadtarget" src="" style="width:0px;height:0px;border:0"></iframe>
    <div id='uploadarea'><p><img src=http://49video.resources.s3.amazonaws.com/loading.gif width=16 height=16>  Loading <a href=http://www.uploadthingy.com>Uploadthingy file upload form</a>... <br><br>If your upload form doesn't display within a few seconds, please check the <a href=http://www.uploadthingy.com/faq.html>FAQ</a> or contact us at hello@uploadthingy.com. We'd love to help out!</p></div>
    <script type="text/javascript" language="Javascript">
    var sitecode="aGV4aGliaXQuY29t";
    authupload();
    function getUploadForm(json) {
    showblinks=false;
    var SECTOR=new Array("Architecture", "Circus", "Dance", "Film", "Literature", "Music", "Opera", "Street arts and spectacle", "Theatre", "Traditional arts", "Visual arts", "Artists supports", "Arts participation", "Festivals and events", "Local arts", "Venues", "Young people, children and education");
    var h="";
    h+="Artform or subject of image<br><select style='width:400px;' id='uploader_artssector'>";
            for (var i=0; i<SECTOR.length; i++) h+="<option value='"+SECTOR[i]+"'>"+SECTOR[i];
    		h+="</select><br><br>";
    h+="<p style='color:gray;'>Your name *<br>";
    h+="<input type=text style='width:500px;' id='uploader_name' name='uploader_name'></p>";
    h+="<p style='color:gray;'>Your organisation *<br>";
    h+="<input type=text style='width:500px;' id='uploader_organisation' name='uploader_organisation'></p>";
    h+="<p style='color:gray;'>How we can contact you *<br>";
    h+="<textarea style='width:500px; height:100px;' id='uploader_contact' name='uploader_contact'></textarea></p>";
    h+="<p style='color:gray;'>Image details<br>";
    h+="<textarea style='width:500px; height:100px;' id='uploader_description' name='uploader_description'></textarea></p>";
    h+="<p style='color:gray;'>Image file<br>";
    h+="<input type='file' size='40' id='uploadfile0' name='file0'><br>";
    h+="</p>";
    h+="<input type='hidden' id='authcode' name='authcode' value='"+json.c+"'>";
    h+="<input type='hidden' id='uploadid' name='id' value='widget$"+json.d+"$"+json.c.substring(0,json.c.indexOf("_"))+"'>";
    h+="<input type='hidden' id='callbackurl' name='callbackurl' value='"+baseserverurl+"'>";
    h+="<input type='hidden' name='savemeta' value='yes'>";
    h+="<p><input class='widget_button' id='49widget_submitbutton' type='button' onclick='doUpload();' name='suploadvideo' value='Upload'></p>";
    return h;
    }
    function doUpload() { if (checkform()) { upload('start'); } }
    function checkform() { 
    var found=false;
    var cnt=0;
    while (document.getElementById('uploadfile'+cnt)) {
    if (document.getElementById('uploadfile'+cnt).value.length>0) {
    found=true;
    break;
    }
    cnt++;
    }
    if (!found) {
    alert('Please select at least one file to upload.');
    return false;
    }
    if (document.getElementById('uploader_name').value.length==0) {
    alert('Please fill out the field: Your name.');
    return false;
    }
    if (document.getElementById('uploader_organisation').value.length==0) {
    alert('Please fill out the field: Your organisation.');
    return false;
    }
    if (document.getElementById('uploader_contact').value.length==0) {
    alert('Please fill out the field: How we can contact you.');
    return false;
    }
    uploadmetadata=new Array();
    uploadmetadata['artssector']=document.getElementById('uploader_artssector').value;
    uploadmetadata['name']=document.getElementById('uploader_name').value;
    uploadmetadata['company']=document.getElementById('uploader_organisation').value;
    uploadmetadata['contact']=document.getElementById('uploader_contact').value;
    uploadmetadata['description']=document.getElementById('uploader_description').value;
    uploadmetadata['uploadfile0']=document.getElementById('uploadfile0').value;
    	return true;
    }
    </script>
    


Comments

  • Registered Users Posts: 7,501 ✭✭✭BrokenArrows


    What is the problem. The test page drop down seems to work fine!


  • Registered Users Posts: 19,309 ✭✭✭✭alastair


    What is the problem. The test page drop down seems to work fine!

    The drop down looks fine - but it's not submitting - unlike the rest of the text fields. :(


  • Registered Users Posts: 19,309 ✭✭✭✭alastair


    I've had thsi sorted by the uploadthingy people, but then added extra form fields and banjaxed it again - waiting to hear back from them on correcting my mistakes.

    cheers.


Advertisement