how can i get the div id's of this form

1346 views javascript

I am trying to make myself an app that imports or upload data or the text that was typed in the app to a particular web page when a button is pressed(the language used is Java if that's necessary). A google form for an example.

I've already worked on how to do the import thing but I have zero clue on how to get the id's or the variable names of a textarea, radio buttons, the div thing.

javascript: (function () {
function WW(ele, val)
    if(document.getElementById(ele) && val != "")
        document.getElementById(ele).value = val;
WW("story-title", "The Good Peacock");

As you can see this is the code, I copied this from some guy.

This works with other sites that have the an id, like:

<textarea id="story-title">

So, I want to know the id's of the code that I will post below.

This is a part of the source code of the website I'm trying to autofill with.

I've tried calling with getElementByClassName() but it still didn't work.

    <form class="main-edit-form">

          <div class="required-form-wrapper">
            <div class="form-group title-form">
              <span class="empty-warning hidden" id="title-warning">Required</span>
              <div contenteditable="true" class="story-title">Untitled Story</div>

            <div class="form-group description-form">
              <div class="form-wrapper">
                <span data-toggle="popover" class="popover-icon" id="description-tooltip" title="" data-original-title="Add a story description"><span class="fa fa-info fa-wp-lightergrey " aria-hidden="true" ></span></span>
                <span class="empty-warning hidden" id="description-warning">Required</span>
              <textarea type="text" name="title" class="story-description "></textarea>

            <div class="form-group tags-form">
              <div class="form-wrapper">
                <span data-toggle="popover" class="popover-icon" id="tags-tooltip" title="" data-original-title="Help readers find your story"><span class="fa fa-info fa-wp-lightergrey " aria-hidden="true" ></span></span>
                <span class="empty-warning hidden" id="tag-empty-warning">Required</span>
              <div class="tag-container">
                <div id="editable-tags">
                  <div class="component-wrapper" id="component-TagGrid-storyTags-/myworks/new"></div>
                <div id="add-tag" class="tag-item with-icon on-add-tag">
                  <span>Add a tag</span><span class="fa fa-plus fa-wp-black " aria-hidden="true" ></span>
                <span id="tag-input-wrapper">
                <input id="tag-input" class="hidden on-tag-input" placeholder="Separate tags with a space" autocomplete="off">

            <div class="form-group inline-form">
              <div class="form-wrapper">
                <label for="categoryselect">Genre</label>
                <span data-toggle="popover" class="popover-icon" id="category-tooltip" title="" data-original-title="Tell Wattpad the genre of your story"><span class="fa fa-info fa-wp-lightergrey " aria-hidden="true" ></span></span>
                <select id="categoryselect" class="form-control ">
                  <option value="-1">Select a genre</option>
                    <option value="14">Action</option>
                    <option value="11">Adventure</option>
                    <option value="24">ChickLit</option>
                    <option value="6">Fanfiction</option>
                    <option value="3">Fantasy</option>
                    <option value="21">General Fiction</option>
                    <option value="23">Historical Fiction</option>
                    <option value="9">Horror</option>
                    <option value="7">Humor</option>

answered question

1 Answer


You can add an id to any element you want by adding


to the tag. In your case, it would be:

<form class="main-edit-form" id="your_id">

Then you can do


to get the element.

posted this

Have an answer?


Please login first before posting an answer.